Skip to content

fix(grep): force --with-filename to fix single-file rg output parsing#1725

Open
ShiraiEd wants to merge 1 commit intortk-ai:developfrom
ShiraiEd:fix/grep-single-file-filename-parse
Open

fix(grep): force --with-filename to fix single-file rg output parsing#1725
ShiraiEd wants to merge 1 commit intortk-ai:developfrom
ShiraiEd:fix/grep-single-file-filename-parse

Conversation

@ShiraiEd
Copy link
Copy Markdown

@ShiraiEd ShiraiEd commented May 5, 2026

Summary

  • rg omits the filename prefix when searching a single file, causing the parser to misread the line number as the filename and truncate content at the
    first colon
  • Added --with-filename to the rg invocation so output always includes the filename prefix regardless of how many files are searched
  • Extracted inline parsing logic into parse_rg_line helper for testability

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Added test_parse_rg_line_with_colons_in_content — verifies filename and line number are correct when content contains colons
  • Added test_parse_rg_line_single_file_fallback — verifies two-part lines fall back to the provided path
  • Manual test: rtk grep "function" test.ts on a file with colon-heavy signatures now correctly returns 2 matches in 1 file with accurate filenames and line numbers

(fixes [#1613])

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants