sinelaw/fresh · error
openFileInSplit: split
Error message
openFileInSplit: split {} does not exist What it means
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.
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.
Example fix
// before
editor.handle_plugin_command("openFileInSplit", &[path, &old_id.to_string()])?;
// after
let id = editor.active_split_id(); // resolve fresh
editor.handle_plugin_command("openFileInSplit", &[path, &id.to_string()])?; Defensive patterns
Strategy: validation
Validate before calling
let valid = editor.active_split_ids(); if !valid.contains(&target_split_id) { target_split_id = valid[0]; } Type guard
fn has_split(editor: &Editor, id: SplitId) -> bool { editor.active_split_ids().contains(&id) } Try / catch
if let Err(e) = editor.handle_plugin_command("openFileInSplit", args) { if e.to_string().contains("does not exist") { editor.open_file(&path)?; } } Prevention
- 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
When it happens
Trigger: 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).
Common situations: Plugin caches split ids across layout changes; user closes splits so ids shift; command invoked after switching to a window with fewer splits.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- previewFileInSplit: split
- preview: split does not exist
- editor.spawnProcess is not implemented (missing…
- editor.spawnHostProcess is not implemented (missing…
- TypeScript plugin thread creation failed
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/592f55f4581c0306.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/plugin_commands.rs:1666
line: Option<usize>,
column: Option<usize>,
) -> AnyhowResult<()> {
// Validate the target split BEFORE touching any buffer state so a
// dead/unknown split id cannot leave an orphan buffer loaded with
// nothing on screen. `set_active_split` returns false when the id
// doesn't resolve to a live leaf (the split was closed, or its last
// tab collapsed it away). Surface that as an error so the failure is
// reported instead of masquerading as success (#2769).
let target_split_id = LeafId(SplitId(split_id));
if !self
.windows
.get_mut(&self.active_window)
.and_then(|w| w.split_manager_mut())
.expect("active window must have a populated split layout")
.set_active_split(target_split_id)
{
tracing::error!("Failed to switch to split {}", split_id);
anyhow::bail!("openFileInSplit: split {} does not exist", split_id);
}
// Open the file in the now-active split
if let Err(e) = self.open_file(&path) {
tracing::error!("Failed to open file from plugin: {}", e);
return Err(e);
}
// Jump to the specified location (or default to start)
self.jump_to_line_column(line, column);
Ok(())
}
/// Handle PreviewFileInSplit: browse a file in `split_id` as the
/// editor's single preview tab, without moving focus there.
///
/// The two failure modes are deliberately not alike. A split id that
/// doesn't resolve is the plugin's bug and is reported (#2769) — theView on GitHub (pinned to 67894ca546)