Skip to content

Fix VS15 applying more than once to the same base character - #244

Merged
jquast merged 4 commits into
masterfrom
fix-vs15-repeated-narrowing
Sep 15, 2026
Merged

jquast merged 4 commits into
masterfrom
fix-vs15-repeated-narrowing

Conversation

@jquast

@jquast jquast commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

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 to
determine 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

afonsojanu and others added 3 commits September 11, 2026 20:21
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

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (784d08c) to head (86dd4ad).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 108 untouched benchmarks


Comparing fix-vs15-repeated-narrowing (86dd4ad) with master (784d08c)

Open in CodSpeed

@jquast
jquast merged commit c0dc90b into master Sep 15, 2026
30 checks passed
@jquast
jquast deleted the fix-vs15-repeated-narrowing branch September 15, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants