{"record":{"id":"96dd89496ae70f09","repo":"sinelaw/fresh","slug":"no-split-layout","errorCode":null,"errorMessage":"no split layout","messagePattern":"no split layout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/app/buffer_management.rs","lineNumber":279,"sourceCode":"    /// handler on purpose: the focus handler commits the preview when it\n    /// moves between splits (\"walking away is commitment\"), which is right\n    /// for a user walking away and wrong for a browse that never left. Same\n    /// reason the cursor jump happens inside the window: `jump_to_line_column`\n    /// moves the active split's cursor, and the target is the active split\n    /// only until this returns.\n    pub fn preview_file_in_split(\n        &mut self,\n        path: &Path,\n        target_split: LeafId,\n        line: Option<usize>,\n        column: Option<usize>,\n    ) -> anyhow::Result<BufferId> {\n        let previous_split = self\n            .windows\n            .get(&self.active_window)\n            .and_then(|w| w.buffers.splits())\n            .map(|(mgr, _)| mgr.active_split())\n            .ok_or_else(|| anyhow::anyhow!(\"no split layout\"))?;\n\n        let set_active = |editor: &mut Self, split: LeafId| -> bool {\n            editor\n                .windows\n                .get_mut(&editor.active_window)\n                .and_then(|w| w.split_manager_mut())\n                .is_some_and(|mgr| mgr.set_active_split(split))\n        };\n\n        if !set_active(self, target_split) {\n            anyhow::bail!(\"preview: split {:?} does not exist\", target_split);\n        }\n\n        let result = self.preview_file(path);\n        if result.is_ok() && (line.is_some() || column.is_some()) {\n            self.jump_to_line_column(line, column);\n        }\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/buffer_management.rs#L261-L297","documentation":"preview_file_in_split needs to know the active split of the current window to open a preview, but the window has no split layout (single leaf, no split tree). buffer_management.rs:279 uses ok_or_else on splits()/active_split() and bails with \"no split layout\".","triggerScenarios":"Calling preview_file_in_split (via handle_preview_file_in_split) when the active window's buffer tree has no splits — windows.get(...).and_then(splits) yields None or active_split() is unavailable.","commonSituations":"Preview keybinding/command executed in a fresh single-pane window before any split was created; scripted automation assuming splits exist; after closing all splits except one.","solutions":["Create a split (split_vertical/split_horizontal) before requesting an in-split preview","Fall back to a regular preview/open in the current pane when no split layout exists","Guard the command: check for an existing split layout and disable the in-split preview action otherwise"],"exampleFix":"// before\nlet id = editor.preview_file_in_split(path)?; // fails without splits\n// after\nif editor.has_split_layout() {\n    let id = editor.preview_file_in_split(path)?;\n} else {\n    let id = editor.preview_file(path)?;\n}","handlingStrategy":"fallback","validationCode":"let has_splits = editor.active_window_splits().is_some();\nif !has_splits { editor.split_horizontal()?; }","typeGuard":"fn can_preview_in_split(editor: &Editor) -> bool {\n    editor.active_window_splits().is_some()\n}","tryCatchPattern":"match editor.preview_file_in_split(path) {\n    Err(e) if e.to_string() == \"no split layout\" => editor.preview_file(path),\n    other => other,\n}","preventionTips":["Ensure a split exists before issuing in-split preview commands","Bind the in-split preview action only in layouts where splits are present","Provide a non-split preview fallback in command handlers"],"tags":["editor","ui-layout","splits","rust"],"backgroundTag":"invalid-state-transition","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"}