{"record":{"id":"592f55f4581c0306","repo":"sinelaw/fresh","slug":"openfileinsplit-split-does-not-exist","errorCode":null,"errorMessage":"openFileInSplit: split {} does not exist","messagePattern":"openFileInSplit: split (.+?) does not exist","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/app/plugin_commands.rs","lineNumber":1666,"sourceCode":"        line: Option<usize>,\n        column: Option<usize>,\n    ) -> AnyhowResult<()> {\n        // Validate the target split BEFORE touching any buffer state so a\n        // dead/unknown split id cannot leave an orphan buffer loaded with\n        // nothing on screen. `set_active_split` returns false when the id\n        // doesn't resolve to a live leaf (the split was closed, or its last\n        // tab collapsed it away). Surface that as an error so the failure is\n        // reported instead of masquerading as success (#2769).\n        let target_split_id = LeafId(SplitId(split_id));\n        if !self\n            .windows\n            .get_mut(&self.active_window)\n            .and_then(|w| w.split_manager_mut())\n            .expect(\"active window must have a populated split layout\")\n            .set_active_split(target_split_id)\n        {\n            tracing::error!(\"Failed to switch to split {}\", split_id);\n            anyhow::bail!(\"openFileInSplit: split {} does not exist\", split_id);\n        }\n\n        // Open the file in the now-active split\n        if let Err(e) = self.open_file(&path) {\n            tracing::error!(\"Failed to open file from plugin: {}\", e);\n            return Err(e);\n        }\n\n        // Jump to the specified location (or default to start)\n        self.jump_to_line_column(line, column);\n        Ok(())\n    }\n\n    /// Handle PreviewFileInSplit: browse a file in `split_id` as the\n    /// editor's single preview tab, without moving focus there.\n    ///\n    /// The two failure modes are deliberately not alike. A split id that\n    /// doesn't resolve is the plugin's bug and is reported (#2769) — the","sourceCodeStart":1648,"sourceCodeEnd":1684,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/plugin_commands.rs#L1648-L1684","documentation":"handle_open_file_in_split bails when set_active_split on the active window's split manager fails, meaning the requested split id doesn't exist in the current layout. The plugin command then refuses to open the file rather than opening it in the wrong split.","triggerScenarios":"A plugin command, handle_split_window, or follow_line_target passes a split id that is absent from the active window's split layout (closed split, wrong window, never created).","commonSituations":"Plugin caches split ids across layout changes; user closes splits so ids shift; command invoked after switching to a window with fewer splits.","solutions":["Query the current split layout to obtain a valid split id before invoking the command.","Recreate the desired split layout before targeting a specific split id.","Fall back to opening the file in the active split when the target is missing."],"exampleFix":"// before\neditor.handle_plugin_command(\"openFileInSplit\", &[path, &old_id.to_string()])?;\n// after\nlet id = editor.active_split_id(); // resolve fresh\neditor.handle_plugin_command(\"openFileInSplit\", &[path, &id.to_string()])?;","handlingStrategy":"validation","validationCode":"let valid = editor.active_split_ids(); if !valid.contains(&target_split_id) { target_split_id = valid[0]; }","typeGuard":"fn has_split(editor: &Editor, id: SplitId) -> bool { editor.active_split_ids().contains(&id) }","tryCatchPattern":"if let Err(e) = editor.handle_plugin_command(\"openFileInSplit\", args) { if e.to_string().contains(\"does not exist\") { editor.open_file(&path)?; } }","preventionTips":["Resolve split ids dynamically, never hardcode them in plugins","Handle layout-change events by invalidating cached ids","Fall back to the active split when a target is absent"],"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"}