sinelaw/fresh · warning
previewFileInSplit: split
Error message
previewFileInSplit: split {} does not exist What it means
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.
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.
Example fix
// before
editor.handle_plugin_command("previewFileInSplit", &[path, "7"])?; // split 7 gone
// after
let target = editor.available_split_ids().first().copied().unwrap_or_default();
editor.handle_plugin_command("previewFileInSplit", &[path, &target.to_string()])?; Defensive patterns
Strategy: try-catch
Validate before calling
let exists = editor.active_window().view_states.contains_key(&target_split); if !exists { return Ok(()); } // preview is best-effort Type guard
fn split_available(editor: &Editor, id: SplitId) -> bool { editor.active_window_view_states().map_or(false, |vs| vs.contains_key(&id)) } Try / catch
// the command already swallows preview failures (logs at debug, returns Ok)
let _ = editor.handle_plugin_command("previewFileInSplit", args); Prevention
- 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
When it happens
Trigger: 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).
Common situations: Plugin issues previewFileInSplit with a hardcoded or stale split id; user restructured the split layout between plugin invocations.
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
- 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/de3497ba93a2d2e8.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/plugin_commands.rs:1707
/// (`LargeFileEncodingConfirmation`), and neither a dialog nor an error
/// belongs in the middle of a live result list. Skip it and log — the
/// same thing the explorer's arrow-key preview does — and leave the
/// full story for the deliberate open the user makes with Enter.
pub(super) fn handle_preview_file_in_split(
&mut self,
split_id: usize,
path: std::path::PathBuf,
line: Option<usize>,
column: Option<usize>,
) -> AnyhowResult<()> {
let target_split = LeafId(SplitId(split_id));
if !self
.windows
.get(&self.active_window)
.and_then(|w| w.buffers.splits())
.is_some_and(|(_, view_states)| view_states.contains_key(&target_split))
{
anyhow::bail!("previewFileInSplit: split {} does not exist", split_id);
}
if let Err(e) = self.preview_file_in_split(&path, target_split, line, column) {
tracing::debug!("previewFileInSplit: skipping preview for {:?}: {}", path, e);
}
Ok(())
}
/// Handle OpenFileInBackground command
pub(super) fn handle_open_file_in_background(&mut self, path: std::path::PathBuf) {
// Open file in a new tab without switching to it
if let Err(e) = self.open_file_no_focus(&path) {
tracing::error!("Failed to open file in background: {}", e);
} else {
tracing::info!("Opened file in background: {:?}", path);
}
}
View on GitHub (pinned to 67894ca546)