Skip to content

Measure hyphen break positions by display width - #261

Closed
jakezwang wants to merge 1 commit into
jquast:masterfrom
jakezwang:fix/wrap-hyphen-display-width
Closed

jakezwang wants to merge 1 commit into
jquast:masterfrom
jakezwang:fix/wrap-hyphen-display-width

Conversation

@jakezwang

Copy link
Copy Markdown
Contributor

wrap('古古-1abcdef', 4) currently produces a first line of 古古-, which occupies five columns. The hyphen search compares codepoint positions with the available display width. It also misses valid hyphen breaks after combining characters.

Find the prefix that fits using the existing grapheme-aware width helper, then search that prefix for the last hyphen. Adds regression cases for CJK text, combining marks, and wide emoji.

Validation: the full test suite passes on Python 3.8–3.14 and 3.15rc (1605 passed, 11 optional data-fixture skips per version). All CI lint, formatting, type, documentation, and package checks pass.

@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (329d19c) to head (1981ab7).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #261   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         2008      2008           
  Branches       469       468    -1     
=========================================
  Hits          2008      2008           

☔ 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 19, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 20.67%

⚠️ 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
✅ 118 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_wrap_japanese 6.6 ms 8.3 ms -20.67%

Tip

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


Comparing jakezwang:fix/wrap-hyphen-display-width (1981ab7) with master (329d19c)

Open in CodSpeed

@jquast

jquast commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Thank you @jakezwang , don’t worry about the codspeed results, I’ll take the PR from here.

@jquast jquast closed this in #262 Sep 20, 2026
hugovk pushed a commit to hugovk/wcwidth that referenced this pull request Sep 30, 2026
Original description:

> wrap('古古-1abcdef', 4) currently produces a first line of 古古-, which occupies five columns. The
> hyphen search compares codepoint positions with the available display width. It also misses valid
> hyphen breaks after combining characters.
>
> Find the prefix that fits using the existing grapheme-aware width helper, then search that prefix
> for the last hyphen. Adds regression cases for CJK text, combining marks, and wide emoji.
>
> Validation: the full test suite passes on Python 3.8–3.14 and 3.15rc (1605 passed, 11 optional
> data-fixture skips per version). All CI lint, formatting, type, documentation, and package checks
> pass.

Closes jquast#261 


---------

Co-authored-by: Jake Wang <[email protected]>
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