Repository navigation
Trim trailing spaces before terminal sequences in Python wrap - #333
Open
PriyansuMaurya wants to merge 2 commits into
Open
PriyansuMaurya wants to merge 2 commits into
PriyansuMaurya wants to merge 2 commits into
Conversation
Use the existing sequence-aware trimming helper when a wrapped line ends in whitespace followed by terminal sequences. Preserve sequence-only inputs and clarify drop_whitespace. Fixes jquast#332.
Add four regressions for both line-breaking modes and SGR propagation settings, plus six controls for drop_whitespace=False and sequence-only input. The four regressions fail on the original implementation.
PriyansuMaurya
force-pushed
the
fix/wrap-trailing-space-before-sequences
branch
from
November 25, 2026 22:56
b362057 to
34e907f
Compare
This branch has not been deployed
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 #332.
wrap('a \x1b[31mlongword\x1b[0m', width=2)leaves a visible space on its first line even withdrop_whitespace=True. The plain-text version trims it. A long word's zero-width style prefix can land at the end of the preceding line, hiding the space fromstr.rstrip().Use the existing
_rstrip_visible()helper in the sequence-ended-line branch when the last visible character is whitespace. Preserve terminal sequences and sequence-only inputs; normal text retains its existing path. Clarify the option's docstring.Ten test cases cover both line-breaking modes, SGR propagation on/off,
drop_whitespace=False, and sequence-only input. Before the fix, four regressions fail and six controls pass.Validation on Linux:
git diff --checkpass.This patch changes the Python wrapper; the standalone C wrapper is outside its scope.