Repository navigation
fix: skip empty UTF-16 lines in nonblank numbering - #4118
Merged
keith-hall merged 2 commits intoNov 7, 2026
Merged
Conversation
keith-hall
approved these changes
Nov 7, 2026
cindykrafft
pushed a commit
to cindykrafft/bat
that referenced
this pull request
Nov 7, 2026
Resolve the src/controller.rs conflict with sharkdp#4118: keep this branch's plain line counter (blank-line handling for -b now lives in the printer, which decodes UTF-16 before checking), and drop the ContentType and UTF_16LE/BE imports that only sharkdp#4118's controller check used. sharkdp#4118's CHANGELOG entry and number_nonblank_utf16 test are kept and pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix nonblank line numbering for UTF-16 input.
The controller checks raw CR/LF bytes when deciding whether to advance the nonblank line counter. UTF-16 line terminators contain NUL bytes, so empty lines incorrectly advance the counter even though the printer hides their numbers. As a result,
alpha\n\nbeta\nis numbered 1, 3 instead of 1, 2.Decode UTF-16 before checking for empty lines, using the same BOM removal and CR/LF predicate as the printer. Keep the byte predicate for other encodings. Add integration coverage for LE/BE BOMs, LF/CRLF, leading/trailing blank lines, and spaces/tabs that must remain numbered, plus a changelog entry.
Validation: the regression failed on the original controller (5 passed, 1 failed, showing
3 betainstead of2 beta). With the fix, the nonblank numbering tests pass (6/6), as do the UTF-16 integration tests (6/6).cargo fmt -- --checkandcargo clippy --locked --all-targets --all-features -- -D warningspass inrust:1.98-bookworm.This change was prepared with AI assistance.