Skip to content

Allow channel matching to only target content fields #1073

Description

@niallobrien

Problem
When using tv text, I expect the interactive search to behave like "search file contents".
Right now, the interactive filter also matches the filename/path portion of each entry, because the
entry is shaped like:

path/to/file.ts:12:4:matched line text here

That means tv text is not strictly content-only from the user's point of view. A query can keep a
result visible because it matches the path, even when the matched line text does not contain that
query.

Feature
Allow a channel to define which field(s) participate in interactive matching, separately from the
displayed row and output value.

Conceptually, something like a match template:

[source]
command = "rg ..."
display = "{path}:{line}:{column}:{text}"
output = "{path}:{line}:{column}"
match = "{text}"

Or the equivalent as a CLI flag for ad-hoc channels.

This would make it possible to:

  • use files for filename/path search
  • use text for content-only search
  • keep the current rich row display and preview behavior

without path text leaking into interactive text matching.

Examples
Example of current behavior:

tv text . \
  --source-command "printf 'src/foo.ts:1:1:hello world\nlib/bar.ts:1:1:nope\n'" \
  --input src \
  --take-1

Current result:

src/foo.ts:1:1

Even though src only appears in the filename/path in this example, the row is still selected.

Example of the proposed configuration:

[source]
command = "rg ..."
display = "{path}:{line}:{column}:{text}"
output = "{path}:{line}:{column}"
match = "{text}"

Additional context
Environment:

  • Television 0.15.7
  • macOS

This would make files and text feel like cleanly separate workflows:

  • files for filename/path matching
  • text for file-content matching

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions