Skip to content

Bugfix Virama, matching uucode (ghostty) - #222

Merged
jquast merged 3 commits into
masterfrom
jq/bugfix-bermese-virama
Jun 4, 2026
Merged

jquast merged 3 commits into
masterfrom
jq/bugfix-bermese-virama

Conversation

@jquast

@jquast jquast commented Jun 4, 2026 •

Copy link
Copy Markdown
Owner

After careful review of Virama width calculation and study of uucode, two related changes:

  • Bugfix Invisible_Stacker viramas now form conjuncts (Burmese, Khmer, etc.)

    Discovered while analyzing Burmese, found in IndicSyllabicCategory.txt, "causes conjunct
    formation", added in Unicode 14.0:

     # Indic_Syllabic_Category=Invisible_Stacker
     #
     # Invisible stacker (usually kills inherent vowel of consonant; is not visible
     #                    by itself; causes conjunct formation or consonant
     #                    stacking)
    

    So this logically belongs with the others in _ISC_VIRAMA_SET. Use code generation instead of
    the copy and paste done before, this set would have changed in several past unicode releases and
    so may change again in the future.

  • Change Virama+consonant width calculation to match @jacobsandlund's uucode (ghostty)

    Our previous implementation was perhaps too complex, but more "giving" for width compared to
    uucode's implementation, and neither of ours really has any basis in standards, seems to be of
    taste. contour's libunicode does not make concern for virama, and uucode's does, measurement
    is simpler to implement and will probably improve performance, see code comment::

      # Virama codepoints (Indic_Syllabic_Category=Virama|Invisible_Stacker)
      # are treated as zero-width combining marks, matching Ghostty's uucode
      # library.  Whether a virama+consonant sequence should collapse to 1 or
      # 2 cells is undefined by Unicode; we follow uucode's (1).
    

Discovered while analyzing Burmese, found in
``IndicSyllabicCategory.txt``, "causes conjunct formation", added in
Unicode 14.0:

    # Indic_Syllabic_Category=Invisible_Stacker
    #
    # Invisible stacker (usually kills inherent vowel of consonant; is not visible
    #                    by itself; causes conjunct formation or consonant
    #                    stacking)

So this logically belongs with the others in _ISC_VIRAMA_SET. Use code
generation instead of the copy and paste done before, this set would
have changed in unicode releases 10, 11, 12, 13, 15, it will probably
change more again in the future.
Comment thread wcwidth/wcwidth.py Fixed
@codecov

codecov Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e7673ff) to head (425ed1d).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #222   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         1548      1513   -35     
  Branches       370       364    -6     
=========================================
- Hits          1548      1513   -35     

☔ 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.

Our previous implementation was perhaps too complex, but more "giving"
for width compared to uucode's implementation, and neither of ours
really has any basis in standards, seems to be of "taste". uucode's is
simpler -- it will probably improve performance, see code comment::

    # Virama codepoints (Indic_Syllabic_Category=Virama|Invisible_Stacker)
    # are treated as zero-width combining marks, matching Ghostty's uucode
    # library.  Whether a virama+consonant sequence should collapse to 1 or
    # 2 cells is undefined by Unicode; we follow uucode's (1).
@jquast
jquast force-pushed the jq/bugfix-bermese-virama branch from 0f06113 to dd857a4 Compare June 4, 2026 02:15
@codspeed

codspeed Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 13.53%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 86 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_wcswidth_brahmic_devanagari 2.5 ms 2.2 ms +14.03%
⚡ test_width_brahmic_devanagari 2.7 ms 2.4 ms +13.03%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jq/bugfix-bermese-virama (425ed1d) with master (e7673ff)

Open in CodSpeed

@jquast
jquast merged commit c7fc868 into master Jun 4, 2026
34 checks passed
@jquast
jquast deleted the jq/bugfix-bermese-virama branch June 4, 2026 02:28
jquast added a commit that referenced this pull request Jun 5, 2026
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