Skip to content

Terminal software identity-assisted wcswidth()#220

Draft
jquast wants to merge 21 commits into
masterfrom
jq/dynawidth
Draft

Terminal software identity-assisted wcswidth()#220
jquast wants to merge 21 commits into
masterfrom
jq/dynawidth

Conversation

@jquast
Copy link
Copy Markdown
Owner

@jquast jquast commented May 25, 2026

Correction Tables

  • Use environment values of TERM_PROGRAM and TERM, and suggest that calling programs to use XTVERSION query result, to hint to width() and similar for wcswidth(term_program='xterm.js'),
    • When set, and it matches the automatic "overrides" tables, a correction is applied.
    • This is made possible by the data gathered by https://ucs-detect.readthedocs.io/ project.
  • Only terminals that can be identified by TERM_PROGRAM, XTVERSION, END, or unique TERM

VS-15 narrows width

Closes #211.

Comment thread wcwidth/table_grapheme_overrides/_registry.py Fixed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6ddc5ea) to head (bf99f90).

Additional details and impacted files
@@            Coverage Diff             @@
##            master      #220    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           23        31     +8     
  Lines         1525      1746   +221     
  Branches       365       401    +36     
==========================================
+ Hits          1525      1746   +221     

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread wcwidth/_wcswidth.py Fixed
Comment thread wcwidth/_width.py Fixed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 25, 2026

Merging this PR will degrade performance by 10.74%

⚠️ 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

❌ 1 regressed benchmark
✅ 87 untouched benchmarks
🆕 20 new benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_wcswidth_short_mixed 32.5 µs 36.4 µs -10.74%
🆕 test_wcswidth_emoji_term_program[xterm.js] N/A 607.3 µs N/A
🆕 test_wcswidth_ri_term_program[ghostty] N/A 374.3 ms N/A
🆕 test_wcswidth_term_program[xterm.js] N/A 523.4 µs N/A
🆕 test_wcswidth_term_program[ghostty] N/A 382.2 µs N/A
🆕 test_wcswidth_vs15_term_program[ghostty] N/A 590.6 µs N/A
🆕 test_wcswidth_wide_term_program[ghostty] N/A 309.5 µs N/A
🆕 test_wcswidth_wide_term_program[xterm.js] N/A 779.1 µs N/A
🆕 test_wcswidth_emoji_term_program[ghostty] N/A 109.1 µs N/A
🆕 test_wcswidth_ri_term_program[xterm.js] N/A 375.4 ms N/A
🆕 test_wcswidth_vs15_term_program[xterm.js] N/A 919.4 µs N/A
🆕 test_wcswidth_vs16_term_program[ghostty] N/A 585.5 µs N/A
🆕 test_wcswidth_vs16_term_program[xterm.js] N/A 888 µs N/A
🆕 test_width_term_program[ghostty] N/A 438.5 µs N/A
🆕 test_width_vs16_term_program[ghostty] N/A 636.6 µs N/A
🆕 test_width_vs16_term_program[xterm.js] N/A 939.3 µs N/A
🆕 test_width_ri_term_program[xterm.js] N/A 375.7 ms N/A
🆕 test_width_ri_term_program[ghostty] N/A 374.5 ms N/A
🆕 test_width_term_program[xterm.js] N/A 579.1 µs N/A
🆕 test_width_vs15_term_program[ghostty] N/A 642.2 µs N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jq/dynawidth (bf99f90) with master (6ddc5ea)

Open in CodSpeed

Comment thread tests/test_term_overrides.py Fixed
@jquast jquast changed the title terminal software-assisted width Terminal software identity-assisted wcswidth() Jun 1, 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.

Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15, U+FE0E?

2 participants