Repository navigation
unexpand: resume tab conversion when backspaces move before last tab stop - #16159
Merged
cakebaker merged 1 commit intoNov 3, 2026
Merged
Conversation
cakebaker
force-pushed
the
fix/unexpand-backspace-tab-conversion-16120
branch
from
November 3, 2026 08:42
5a5c713 to
124a476
Compare
Contributor
|
Thanks! |
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.
Fixes #16120
Summary
When unexpanding with a finite tab-stop list (e.g. -t 3,5), \unexpand_buf\ previously fast-forwarded and dumped the remaining buffer as soon as \print_state.col >= lastcol. However, if subsequent backspaces (\b) occurred in the buffer, the column would move back below \lastcol, where spaces should once again be converted to tabs according to GNU \unexpand.
This PR ensures we only fast-forward when the remaining buffer does not contain backspaces (!buf[byte..].contains(&b'\x08')), allowing backspaces to decrease the column and resume tab conversion as expected.
Verification
Added test case in \ ests/by-util/test_unexpand.rs\ with input \�bcde\b\b X\n\ and -t 3,5, verifying that the two spaces are converted to a tab (\t), matching GNU coreutils.
All tests pass.