Skip to content

terminal software-assisted width#220

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

terminal software-assisted width#220
jquast wants to merge 19 commits into
masterfrom
jq/dynawidth

Conversation

@jquast
Copy link
Copy Markdown
Owner

@jquast jquast commented May 25, 2026

Use environment values of TERM_PROGRAM and TERM, and suggest that calling programs to use XTVERSION query result, to hint to width() and 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, or unique TERM (eg. rio, contour, alacritty, kitty, etc. all have custom TERM) are supported. Although we gather data for other terminals, we don't bother to publish corrections if nobody can automatically use it.

VS-15 support is also re-introduced, now that we can properly account for it and its overrides, and, that ghostty and kitty (and more recently, AbsoluteTelnet/SSH beta) matches our interpretation of standard, we can label the others as a common set of overrides by term_program where identifiable.

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 (94139c4).

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

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

⚠️ 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_emoji_term_program[ghostty] N/A 109.1 µs N/A
🆕 test_wcswidth_emoji_term_program[xterm.js] N/A 606.4 µs N/A
🆕 test_wcswidth_ri_term_program[ghostty] N/A 374.3 ms N/A
🆕 test_wcswidth_ri_term_program[xterm.js] N/A 375.4 ms N/A
test_wcswidth_short_mixed 32.5 µs 36.5 µs -10.91%
🆕 test_wcswidth_term_program[ghostty] N/A 382.1 µs N/A
🆕 test_wcswidth_term_program[xterm.js] N/A 523.9 µs N/A
🆕 test_wcswidth_vs15_term_program[ghostty] N/A 589.5 µs N/A
🆕 test_wcswidth_vs15_term_program[xterm.js] N/A 919 µs N/A
🆕 test_wcswidth_vs16_term_program[ghostty] N/A 585.4 µs N/A
🆕 test_wcswidth_vs16_term_program[xterm.js] N/A 889 µs N/A
🆕 test_wcswidth_wide_term_program[ghostty] N/A 310 µs N/A
🆕 test_wcswidth_wide_term_program[xterm.js] N/A 780.4 µs N/A
🆕 test_width_ri_term_program[ghostty] N/A 374.4 ms N/A
🆕 test_width_ri_term_program[xterm.js] N/A 375.6 ms N/A
🆕 test_width_term_program[ghostty] N/A 438.4 µs N/A
🆕 test_width_term_program[xterm.js] N/A 578.6 µs N/A
🆕 test_width_vs15_term_program[ghostty] N/A 641.8 µs N/A
🆕 test_width_vs15_term_program[xterm.js] N/A 972.4 µs N/A
🆕 test_width_vs16_term_program[ghostty] N/A 636.8 µ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 (94139c4) with master (6ddc5ea)

Open in CodSpeed

Comment thread tests/test_term_overrides.py Fixed
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