Skip to content

Show context snippets for content: search results #212

Description

@franciscoxc

Feature request

When a search uses the content: filter, Cardinal currently returns the matching files but the result list does not show where the match happened inside each file.

It would be helpful to show a dedicated Context column when the query includes content:. This column could display a short snippet around the matched text and highlight the matched term.

Suggested behavior

  • Keep the current result columns unchanged for normal filename/path searches.

  • When the active query includes content:, show an additional Context column.

  • For each visible result row, show a short excerpt from the file around the first content match, for example:

    ...text before the matched term and text after...
    
  • Highlight or bold the matched content: term inside the snippet.

  • If no snippet can be read for a file, leave the cell empty or show a subtle placeholder.

Scope for an MVP

This proposal would not change the current content: semantics. Cardinal currently treats content: as a plain substring match:

  • content:"foo bar" matches the exact substring foo bar.
  • content:foo content:bar can be used to find files containing both terms, even when they are separated.

For the MVP, the Context column can follow that same behavior and show context for the literal content: term that matched.

To keep performance predictable, snippets could be loaded lazily only for visible rows, similar to how row metadata/icons are already hydrated.

Motivation

When using content:, the file path alone is often not enough to understand why a result matched. A small context preview would make content searches easier to scan and would help users decide which result to open.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions