Skip to content

fix(search): display nb line only if requested - #3182

Merged
aeppling merged 5 commits into
developfrom
fix/grep-transparency
Jul 28, 2026
Merged

aeppling merged 5 commits into
developfrom
fix/grep-transparency

Conversation

@aeppling

Copy link
Copy Markdown
Contributor

Line numbers now appear only when the agent requests them (-n / --line-number); -N / --no-line-number still force them off.

Adrien EPPLING and others added 2 commits July 23, 2026 12:54
show_line() emitted a `<lineno>:` prefix on every match by default,
suppressed only by -N. That diverges from grep (which shows line numbers
only with -n), so `cargo test | grep "test result:"` came back as
`266:test result: ...` and broke downstream parses like
`grep X | awk -F: '{print $1}'` -- violating RTK's transparency goal
(issue #1436) and driving agent retries in benchmarking.

Line numbers now appear only when the agent requests them (-n /
--line-number); -N / --no-line-number still force them off. grep -c and
exit codes are untouched (already faithful). Tests rebased onto the
plain-grep baseline.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EeBpaGF4TJsNWz12h6Sk3G
match_block hardcoded `path:line:content`, so overflow recovered via a
`+N more ... tail` hint carried a filename/line prefix the original grep
never showed (e.g. plain single-file grep). Mirror the primary output's
show_file/show_line so recovery is a faithful continuation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EeBpaGF4TJsNWz12h6Sk3G
@CLAassistant

CLAassistant commented Jul 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ aeppling
❌ Adrien EPPLING


Adrien EPPLING seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@aeppling
aeppling marked this pull request as ready for review July 28, 2026 09:07
aeppling added 3 commits July 28, 2026 11:33
…line"

This reverts commit 792f432.

The tee block is recovery state, not command output. Mirroring the
display's show_file/show_line meant a plain `rtk grep pat file` that
capped at 25 of 100 matches wrote the 75 dropped ones to the tee as bare
content lines: no path, no line number, nothing to open. Nobody diffs the
tee against grep, so faithfulness buys nothing there and costs the one
property the tee exists for.

The display stays faithful, which was the point of 608e574: no -n means
no line numbers, -n means line numbers, byte-identical to grep both ways.
Only the recovery block goes back to being fully qualified.

Also:
- lock both halves with tests (match_block had none): show_line off by
  default / on for -n, --line-number and short clusters / off for -N,
  and match_block staying path:line:content when the display drops both
- fix the now-false module doc in grep_faithful_format_test.rs, which
  still claimed byte-identity with `grep -n` and "line number always",
  and drop the stale _grep_n suffixes from its test names
- drop a comment duplicating the show_file/show_line block above it
Strip the explanatory comments the branch accumulated and restore
match_block byte-for-byte to develop, so the diff is only what the
transparency fix needs: show_line() flips from opt-out to opt-in, plus
tests. Compression, capping and tee recovery are untouched.

Also drops a comment in run() that the flip made false.
Swapping the grep_n helper for grep_plain moved every scenario from the
-n path to the plain path, leaving exactly one assertion covering line
numbers. Both directions matter now that -n decides whether they appear,
so assert_eq_grep_with_and_without_n runs each case twice and the piped
stdin test loops over both forms.

Mutation-checked: reverting show_line to the old always-on form fails 10
of the 11 tests in this file.
@aeppling
aeppling merged commit a8b9eb3 into develop Jul 28, 2026
15 of 17 checks passed
@aeppling aeppling mentioned this pull request Jul 28, 2026
@TaKO8Ki
TaKO8Ki deleted the fix/grep-transparency branch July 28, 2026 17:20
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.

3 participants