Repository navigation
fix(grep): preserve -- separator between non-adjacent match blocks - #2836
Conversation
|
Hey @guyoron1 , thanks for the contribution it solve the core problem of #2795 One blocker before merge; Repro: rtk grep -rn todo # here lot of -- printed Single large file behaves the same: grep -n match huge.txt, native 0 but rtk 24. The output ends up with a -- between essentially every match. Should gate the insertion so it runs when actually requested context. |
When context flags (-A/-B/-C) are used, grep prints -- between non-adjacent match blocks. parse_match_line() returned None for this separator, and both output paths silently dropped it, merging distinct matches into one contiguous block. Fixes rtk-ai#2795
Native grep only prints -- between non-adjacent match blocks when -A/-B/-C context is requested. The grouped output path was inserting -- on any line-number gap unconditionally, so `rtk grep -rn todo` invented separators between every match that grep never emits. Gate the insertion on has_context_flag() which checks for -A/-B/-C and their long-form equivalents.
6c7f526 to
34a0f0e
Compare
|
Hey @guyoron1 , thanks for the fix, LGTM Thanks for contributing to RTK ! |
|
woohoooooo yay ! |
|
Heyaaaa! I've actually faced a very similar issue on #2751 — the benchmark The benchmark gate has passed on the latest CI runs, but the The never-worse guard (#2554) works correctly within a single RTK execution, but the benchmark's cross-execution comparison is structurally flaky for live endpoints. Filed #2842 to fix the benchmark by replacing live HTTP calls with local fixtures. This PR only touches grep filter code ( |
Summary
grep -A/-B/-Ccontext output was dropping the--group separator between non-adjacent match blocks--in both the faithful baseline and grouped output pathsFixes #2795
Test plan
group_separator_between_non_adjacent_matches)context_group_separator_matches_grep_n)grep -n -A1exactlycargo fmt && cargo clippy --all-targets && cargo test --allpasses