denisidoro/navi · critical

No files found

Error message

No files found

What it means

Raised in `act` in src/commands/core/actor.rs (src/commands/core/actor.rs:223) via `file_index.expect("No files found")` when the user presses ctrl-o to open a file in an external editor, but the extracted `file_index` is None — meaning the finder selection did not resolve to any file in the `files` list.

Source

Thrown at src/commands/core/actor.rs:223

pub fn act(
    extractions: Result<(&str, Item)>,
    files: Vec<String>,
    variables: Option<VariableMap>,
) -> Result<()> {
    let (
        key,
        Item {
            tags,
            comment,
            snippet,
            file_index,
            ..
        },
    ) = extractions.unwrap();

    if key == "ctrl-o" {
        edit::edit_file(Path::new(&files[file_index.expect("No files found")]))
            .expect("Could not open file in external editor");
        return Ok(());
    }

    env_var::set(env_var::PREVIEW_INITIAL_SNIPPET, &snippet);
    env_var::set(env_var::PREVIEW_TAGS, &tags);
    env_var::set(env_var::PREVIEW_COMMENT, comment);

    let interpolated_snippet = {
        let mut s = replace_variables_from_snippet(
            &snippet,
            &tags,
            variables.expect("No variables received from finder"),
        )
        .context("Failed to replace variables from snippet")?;
        s = with_absolute_path(s);
        s = deser::with_new_lines(s);
        s

View on GitHub (pinned to f7330b9ad5)

Solutions

  1. Only press ctrl-o when the selected entry corresponds to an actual file path
  2. Ensure the underlying command outputs valid file paths so the file index can be populated
  3. Re-select an entry after filtering so the index matches the current file list
  4. Report/patch the panic path: return a proper error instead of `expect` when file_index is None

Example fix

// before
edit::edit_file(Path::new(&files[file_index.expect("No files found")]))
// after
match file_index {
    Some(i) => edit::edit_file(Path::new(&files[i]))?,
    None => anyhow::bail!("No files found"),
}
Defensive patterns

Strategy: type-guard

Validate before calling

// wrap the action: only allow ctrl-o when a file is actually selected
let can_open = selection_is_file && file_index.is_some();
if !can_open { eprintln!("No file selected; ctrl-o requires a file entry"); }

Type guard

fn has_file_index(idx: &Option<usize>) -> bool { idx.is_some() }

Try / catch

// if you wrap the binary/process: treat a panic on ctrl-o as "no file selected"
// and re-run with a plain file-producing snippet
let status = child.wait()?;
if !status.success() && stderr.contains("No files found") {
    eprintln!("Selection was not a file; choose a file-backed entry.");
}

Prevention

When it happens

Trigger: Pressing ctrl-o in the interactive UI when the current selection has no associated file index — e.g. the matched entry came from a command that produced no file paths, or the results list was empty/out of sync with `files`.

Common situations: Running a snippet whose output lines are not file paths and then pressing ctrl-o; stale selection after the file list was re-filtered; invoking the action on a preview/comment-only entry.

Related errors


AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03). Data as JSON: /api/errors/b5b76cdbe098b232. Report an issue: GitHub.