Repository navigation
Make -r and -H use file line numbers with -b - #4084
cindykrafft wants to merge 3 commits into
Conversation
With --number-nonblank the controller's line counter skipped blank lines, and that counter also drives --line-range, --highlight-line and the line-1 BOM strip, so ranges and highlights addressed non-blank line numbers. Count file lines again and keep a separate non-blank count in the printer for the displayed number. Also fill in sharkdp#4076 in its CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
|
Additional CLI checks of @cindykrafft's fix compared A 14-line fixture has nonblank content on physical lines 1, 3, 6, 7, 9, 11 and 14. With For All 16 comparisons (32 CLI processes) produced these expected results. Paging/config loading were disabled and an ANSI theme exposed highlighting. Clean package builds avoided cached same-version base-library reuse. This is focused CLI evidence; the full suite, fmt/clippy, CI and other platforms were not run. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
Resolve the CHANGELOG conflict by keeping the new sharkdp#4091 entry along with the filled-in sharkdp#4076 and sharkdp#4084 entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
With the new
-b/--number-nonblank(#3857, unreleased),--line-rangeand--highlight-lineaddress the non-blank line count instead of file lines, so the same range shows different lines than with-n:and
bat -b -H 5 f.txthighlights nothing (there is no 5th non-blank line) instead offive.cat -bonly changes the displayed numbers, and neither #3857 nor #3856 mentions ranges or highlights, so I assumed this wasn't intended; happy to be told otherwise.Cause: in
src/controller.rsthe line counter skipped blank lines in-bmode, but the same counter drives the range and highlight checks (and the line-1 BOM strip). This counts file lines again and keeps a separate non-blank counter in the printer for the displayed number, so-boutput is unchanged without-r/-H.Tests:
number_nonblank_line_range_uses_file_line_numbersandnumber_nonblank_highlight_line_uses_file_line_numbersintests/integration_tests.rsfail on master and pass with the change; the existing-btests are unchanged. Fullcargo test(458 passed),cargo fmt --checkandcargo clippy --all-targetsare clean. The CHANGELOG also fills in#4076for my earlier entry, which was merged with a placeholder.Disclosure: this was found, reproduced and patched by an AI agent (Claude Code), which ran the reproduction and tests quoted above. It has not been separately reviewed by a human.