Canop/broot · error

syntactic view without pattern shouldn't be none

Error message

syntactic view without pattern shouldn't be none

What it means

Invariant check in Preview::with_mode: when building the Text (syntactic) preview for a regular file, the underlying TextView/syntactic view construction unexpectedly returned None even though no pattern filtering applies. Since a syntactic view of a plain file should always succeed, this panic flags an internal assumption violation (e.g. the syntactic view engine failed to produce a view for a readable file).

Solutions

  1. Check the file is a regular, readable text file before requesting a Text preview
  2. Report the file and mode to broot maintainers — this panic indicates an internal bug, not user error
  3. As a workaround, preview the file in a different mode (Hex, Image, Tty, or Diff)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/preview/preview.rs:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Canop/broot@17204794d7 (2026-09-08). Data as JSON: /api/errors/f80190f22db683f3. Report an issue: GitHub.

Appendix: source

Thrown at src/preview/preview.rs:99

        con: &AppContext,
    ) -> Result<Self, ProgramError> {
        if path.is_file() {
            match mode {
                PreviewMode::Diff => UnifiedDiffView::new(path, con).map(Self::Diff),
                PreviewMode::Hex => Ok(HexView::new(path.to_path_buf()).map(Self::Hex)?),
                PreviewMode::Image => ImageView::new(path).map(Self::Image),
                PreviewMode::Tty => TtyView::new(path)
                    .map(Self::Tty)
                    .map_err(ProgramError::from),
                PreviewMode::Text => Ok(TextView::new(
                    path,
                    InputPattern::none(),
                    &mut Dam::unlimited(),
                    con,
                    false,
                )
                .transpose()
                .expect("syntactic view without pattern shouldn't be none")
                .map(Self::Text)?),
            }
        } else {
            Ok(Self::dir(
                path,
                InputPattern::none(),
                &Dam::unlimited(),
                con,
            ))
        }
    }

    /// build a dir preview
    pub fn dir(
        path: &Path,
        pattern: InputPattern,
        dam: &Dam,
        con: &AppContext,

View on GitHub (pinned to 17204794d7)