Repository navigation
Fix VS15 applying more than once to the same base character - #244
Merged
Merged
Conversation
VS16 clears last_measured_idx once it has adjusted the pending cluster width, specifically to stop a second VS16 from reapplying to the same base character. The VS15 branch right below it does the same kind of adjustment but never got that reset, so a base character followed by two VS15 selectors in a row gets narrowed twice instead of once, and three in a row narrows it three times. Since a wide character can only lose one column going from wide to narrow, every VS15 past the first one is quietly stealing a column that belongs to whatever comes next in the string. This affected width(), wcswidth(), and wcstwidth(), each of which carries its own copy of the VS15 handling. Added a test covering all three plus the case where a trailing character follows the repeated selectors, since that's where the corruption actually becomes visible downstream.
- fix docformatter lint - reduce excess comments - rename 'base' to 'watch' variable - add test_vs16_repeated_ignored()
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #244 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 1980 1983 +3
Branches 464 464
=========================================
+ Hits 1980 1983 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Do not re-apply "narrowing" of a base character with repeated VS-15. Closes #241.
This change is not conforming to any known unicode standard, an errant/extra vs15 or other combining
character is already split or determined by grapheme clustering. This is only accepted because it
is so small and otherwise harmless.
I consider these "glitch unicode", they do not occur naturally in the wild except by a kind of
/dev/urandom(or fuzzing) of codepoints. This library generally takes a stance against trying todetermine accurate measurements of "non-recommended sequences", especially if it hurts performance.
In this case, the index is easy to update (its a one line change), and we're already in VS-15 branch
conditional so it is not harmful for general performance. Note that VS-15 behavior is also
contested, #234