Skip to content

Keep combining characters with hyphens when wrapping long words - #309

Closed
Apeksha9389 wants to merge 1 commit into
jquast:masterfrom
Apeksha9389:fix/wrap-hyphen-graphemes
Closed

Apeksha9389 wants to merge 1 commit into
jquast:masterfrom
Apeksha9389:fix/wrap-hyphen-graphemes

Conversation

@Apeksha9389

Copy link
Copy Markdown

When a long word contains a hyphen followed by a combining mark, wrap() currently breaks immediately after the hyphen, moving the mark to the next line. For example, wrap("ab-\u0301cdef", 4) returns ["ab-", "\u0301cdef"].

Include the hyphen's entire grapheme when selecting a hyphen break, then map that boundary back through terminal sequences. The result keeps the accent with its hyphen: ["ab-\u0301", "cdef"].

Validation:

  • Six new regressions fail before the fix and pass afterward: combining accent, ZWJ and multiple combining marks, each with and without SGR coloring.
  • Full suite with the compiled extension: 1,807 passed, 13 skipped.
  • Full pure-Python suite: 1,771 passed, 49 skipped.
  • Flake8 on changed files, strict MyPy across wcwidth, isort checks and git diff --check pass.

Developed and tested with OpenAI Codex assistance.

@jquast

jquast commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Can you cite any sources, modern or historic, english or other languages, where ascii hyphen '-' is combined with a combining character?

@Apeksha9389

Copy link
Copy Markdown
Author

I don’t have an attested modern or historical language example of ASCII - combined with an accent, and I couldn’t find one in the sources I checked. The examples in this PR are synthetic regression inputs, not text from a real-world report; I should have made that limitation explicit.

My rationale was the wrapper’s documented guarantee to preserve grapheme boundaries. Unicode’s default grapheme rules GB9/GB9a explain why these inputs form a cluster, but that is not evidence of actual linguistic usage. This is a boundary-consistency edge case; I cannot substantiate a practical language-use case for it.

@jquast

jquast commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@jquast jquast closed this Nov 9, 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