Skip to content

text: keep wrapped lines within wrapLen when a wide rune would overflow - #435

Merged
jedib0t merged 1 commit into
jedib0t:mainfrom
TheNetherWatcher:fix-wrap-wide-rune-overflow
Oct 19, 2026
Merged

jedib0t merged 1 commit into
jedib0t:mainfrom
TheNetherWatcher:fix-wrap-wide-rune-overflow

Conversation

@TheNetherWatcher

Copy link
Copy Markdown
Contributor

Proposed Changes

  • appendChar now breaks the line before writing a rune when the line is non-empty and lineLen + RuneWidth(char) > wrapLen, so WrapHard/WrapSoft/WrapText (and tables using WidthMax) never emit lines wider than wrapLen for wide (CJK) runes. A wide rune that can never fit (e.g. wrapLen 1) is placed on its own line; zero-width combining marks now stay with their base rune instead of being split onto the next line.
  • wrapHard/wrapSoft terminate the line when lineLen >= wrapLen (was ==), so the inter-word space isn't appended to an already-full line.
  • Corrected the test added in fix: wrap wide runes when wrapLen is odd in WrapHard #408 (WrapHard("世世世世世世", 3) now yields "世\n世\n世\n世\n世\n世"), added wide-rune tests for all three wrap functions (incl. escape sequences), and a table test checking that rows match the border width with WidthMax: 3 and CJK content.

Fixes #434.

@coveralls

coveralls commented Oct 10, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39306915940

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 8 of 8 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 5164
Covered Lines: 5164
Line Coverage: 100.0%
Coverage Strength: 1.21 hits per line

💛 - Coveralls

@jedib0t
jedib0t force-pushed the fix-wrap-wide-rune-overflow branch from 16037b7 to cc09e35 Compare October 19, 2026 18:57
@sonarqubecloud

Copy link
Copy Markdown

@jedib0t
jedib0t merged commit 9a59d89 into jedib0t:main Oct 19, 2026
3 checks passed
@jedib0t

jedib0t commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix.

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.

text: Wrap* produce lines one column wider than wrapLen with wide (CJK) runes

3 participants