{"record":{"id":"de3497ba93a2d2e8","repo":"sinelaw/fresh","slug":"previewfileinsplit-split-does-not-exist","errorCode":null,"errorMessage":"previewFileInSplit: split {} does not exist","messagePattern":"previewFileInSplit: split (.+?) does not exist","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/fresh-editor/src/app/plugin_commands.rs","lineNumber":1707,"sourceCode":"    /// (`LargeFileEncodingConfirmation`), and neither a dialog nor an error\n    /// belongs in the middle of a live result list. Skip it and log — the\n    /// same thing the explorer's arrow-key preview does — and leave the\n    /// full story for the deliberate open the user makes with Enter.\n    pub(super) fn handle_preview_file_in_split(\n        &mut self,\n        split_id: usize,\n        path: std::path::PathBuf,\n        line: Option<usize>,\n        column: Option<usize>,\n    ) -> AnyhowResult<()> {\n        let target_split = LeafId(SplitId(split_id));\n        if !self\n            .windows\n            .get(&self.active_window)\n            .and_then(|w| w.buffers.splits())\n            .is_some_and(|(_, view_states)| view_states.contains_key(&target_split))\n        {\n            anyhow::bail!(\"previewFileInSplit: split {} does not exist\", split_id);\n        }\n\n        if let Err(e) = self.preview_file_in_split(&path, target_split, line, column) {\n            tracing::debug!(\"previewFileInSplit: skipping preview for {:?}: {}\", path, e);\n        }\n        Ok(())\n    }\n\n    /// Handle OpenFileInBackground command\n    pub(super) fn handle_open_file_in_background(&mut self, path: std::path::PathBuf) {\n        // Open file in a new tab without switching to it\n        if let Err(e) = self.open_file_no_focus(&path) {\n            tracing::error!(\"Failed to open file in background: {}\", e);\n        } else {\n            tracing::info!(\"Opened file in background: {:?}\", path);\n        }\n    }\n","sourceCodeStart":1689,"sourceCodeEnd":1725,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/plugin_commands.rs#L1689-L1725","documentation":"handle_preview_file_in_split validates that the target split exists in the active window's buffer view states before previewing, bailing with the split id when it doesn't. Unlike the open variant, it logs the preview failure at debug and still returns Ok, since previewing is best-effort.","triggerScenarios":"handle_plugin_command invoking previewFileInSplit with a split id not present in the active window's view_states (split closed, wrong window, invalid id from the plugin).","commonSituations":"Plugin issues previewFileInSplit with a hardcoded or stale split id; user restructured the split layout between plugin invocations.","solutions":["Enumerate valid split ids from the active window and pick an existing one in the plugin.","Create the split first, then call previewFileInSplit with the new id.","Treat the error as best-effort: the command already returns Ok and logs at debug; fix the id source in the plugin."],"exampleFix":"// before\neditor.handle_plugin_command(\"previewFileInSplit\", &[path, \"7\"])?; // split 7 gone\n// after\nlet target = editor.available_split_ids().first().copied().unwrap_or_default();\neditor.handle_plugin_command(\"previewFileInSplit\", &[path, &target.to_string()])?;","handlingStrategy":"try-catch","validationCode":"let exists = editor.active_window().view_states.contains_key(&target_split); if !exists { return Ok(()); } // preview is best-effort","typeGuard":"fn split_available(editor: &Editor, id: SplitId) -> bool { editor.active_window_view_states().map_or(false, |vs| vs.contains_key(&id)) }","tryCatchPattern":"// the command already swallows preview failures (logs at debug, returns Ok)\nlet _ = editor.handle_plugin_command(\"previewFileInSplit\", args);","preventionTips":["Treat previews as non-critical and fail soft","Validate split ids against view_states before invoking","Refresh plugin-held ids after any split layout change"],"tags":["editor","plugins","split-layout"],"backgroundTag":"entity-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}