sinelaw/fresh · error
preview: split does not exist
Error message
preview: split {:?} does not exist What it means
preview_file_in_split fails when the requested split id cannot be found in the active window's split manager, so set_active_split returns false. The editor refuses to activate a preview in a split that no longer exists rather than silently previewing elsewhere.
Solutions
- Re-resolve the split id from the active window's split manager before calling preview_file_in_split.
- Check that the split still exists (e.g. view_states/split list contains the id) and bail gracefully with a user message instead of erroring.
- Fall back to preview_file in the current split when the target split is missing.
Example fix
// before
editor.preview_file_in_split(&path, stale_split_id, None, None)?;
// after
if editor.split_exists(stale_split_id) {
editor.preview_file_in_split(&path, stale_split_id, None, None)?;
} else {
editor.preview_file(&path)?;
} Defensive patterns
Strategy: validation
Validate before calling
if !editor.split_exists(target_split) { return; } // check before preview_file_in_split Type guard
fn split_exists(editor: &Editor, id: SplitId) -> bool { editor.active_window_splits().map_or(false, |s| s.contains(&id)) } Try / catch
match editor.preview_file_in_split(&path, target_split, line, column) { Err(e) if e.to_string().contains("does not exist") => editor.preview_file(&path), r => r } Prevention
- Never cache split ids across layout changes; resolve them per invocation
- Check the active window before targeting a split
- Fall back to the current split on missing targets
When it happens
Trigger: Calling preview_file_in_split (via handle_preview_file_in_split) with a target_split id that was closed, was never created, or belongs to a different window than the currently active window.
Common situations: A plugin or keybinding caches a split id, the user closes that split, then triggers a preview; switching active windows so the cached id isn't valid in the new window's split manager.
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
- openFileInSplit: split
- previewFileInSplit: split
- Cannot reload: buffer has unsaved modifications
- Line indexing not available for this document
- Invalid range: start offset
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/3d3676cef6f1371a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/buffer_management.rs:290
column: Option<usize>,
) -> anyhow::Result<BufferId> {
let previous_split = self
.windows
.get(&self.active_window)
.and_then(|w| w.buffers.splits())
.map(|(mgr, _)| mgr.active_split())
.ok_or_else(|| anyhow::anyhow!("no split layout"))?;
let set_active = |editor: &mut Self, split: LeafId| -> bool {
editor
.windows
.get_mut(&editor.active_window)
.and_then(|w| w.split_manager_mut())
.is_some_and(|mgr| mgr.set_active_split(split))
};
if !set_active(self, target_split) {
anyhow::bail!("preview: split {:?} does not exist", target_split);
}
let result = self.preview_file(path);
if result.is_ok() && (line.is_some() || column.is_some()) {
self.jump_to_line_column(line, column);
}
// Back to where the user actually is. `previous_split` was live a
// moment ago; if the open collapsed it (it cannot — a preview open
// adds a buffer, it doesn't close splits) the id simply won't set.
set_active(self, previous_split);
result
}
/// Drop the current preview tab, if any: the browse is over and was not
/// committed. Closes the preview buffer so the split falls back to what
/// it was showing before.View on GitHub (pinned to 67894ca546)