Repository navigation
Fix the first line of UTF-16BE input swallowing the second line - #4076
Merged
Merged
Conversation
In UTF-16BE a newline is 00 0A, so the initial read_until(b'\n') usually already ends exactly at the end of line 1. The BE branch then always called read_utf16_line, which read on to the next newline, merging lines 1 and 2. Only keep reading when the first read did not end on a complete 00 0A. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
keith-hall
enabled auto-merge
October 17, 2026 11:29
cindykrafft
pushed a commit
to cindykrafft/bat
that referenced
this pull request
Oct 20, 2026
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 <[email protected]> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
cindykrafft
pushed a commit
to cindykrafft/bat
that referenced
this pull request
Nov 2, 2026
Resolve the CHANGELOG conflict with sharkdp#4102 and sharkdp#4103: keep their new entries, keep this PR's sharkdp#4084 entry, and point the UTF-16BE entry back at sharkdp#4076 (the merge of sharkdp#4102 had filled its placeholder with sharkdp#4102). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
cindykrafft
pushed a commit
to cindykrafft/bat
that referenced
this pull request
Nov 2, 2026
Brings in sharkdp#4038, sharkdp#4048 and sharkdp#4070. The merge of sharkdp#4048 re-added the old UTF-16BE CHANGELOG entry with its "#XXXX" placeholder at the top of Bugfixes, so drop that duplicate; the entry this PR corrects to sharkdp#4076 stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
cindykrafft
pushed a commit
to cindykrafft/bat
that referenced
this pull request
Nov 4, 2026
Resolve the CHANGELOG conflict: keep the sharkdp#4111 and sharkdp#4110 entries and drop the stale UTF-16BE '#XXXX' duplicate (the entry is listed as sharkdp#4076). 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.
UTF-16BE files (with a BOM) of two or more lines show their first two lines as one: line numbers are off from line 2 on,
--line-rangepicks the wrong lines and the first two lines are highlighted together.InputReader::try_new(src/input.rs) first reads up to a\nbyte. In UTF-16BE a newline is00 0A, so that read usually already ends exactly at the end of line 1, but the BE branch added in #3369 then always callsread_utf16_line, which reads on to the next newline. The extra read is only needed when the0x0Abyte belonged to another character (e.g. U+4E0A, as intest_UTF-16BE-complicated.txt), which is why the existing tests don't catch it:utf16beuses that fixture, andutf16runstest_UTF-16BE.txtwith--plain, where a merged line prints the same text.The fix skips the extra read when the first read already ended on a complete
00 0A(even length). UTF-16LE is unaffected.Tests: new
utf16be_first_line_not_merged_with_secondintests/integration_tests.rsfails on master and passes with the change;cargo test,cargo fmt --checkandcargo clippy --all-targetsare clean. Open PR #3763 also editstry_new(first-line reading for #2262) but leaves the UTF-16 branches alone, so the two may need a trivial rebase.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.