Skip to content

Conversation

@jquast
Copy link

@jquast jquast commented Jan 25, 2026

  • Bugfix In _CustomTextWrap._handle_long_word(), on master branch or this branch when optional co-dependency wcwidth<0.3.0:

    • east-asian characters were measured using len() but should use width-aware self._len().
    • Tests are provided to exercise this.
  • Improve word-wrapping with unicode, starting wcwidth version 0.3.0, the wrap(), and width() functions also parse sequences pretty much the same, even a bit better by "tracking" more kinds of SGR sequences and "reducing" them a bit better on line breaks.

    • optional wcwidth>=0.5.1 handles grapheme boundaries better for many kinds of languages, or just flags and emojis and significantly improved performance over 0.2.14.

note

  • Because almost all users will not know to install the optional "wide" version, they may also have wcwidth at an older version installed by chance. hasattr() must be used for some defense of this circumstance.
    • a special test fixture is used to exercise both possibilities even when latest wcwidth is installed by a mock "wcwidth" module that pretends to be without wrap().

@jquast jquast marked this pull request as draft January 26, 2026 20:03
@jquast

This comment was marked as resolved.

@jquast jquast marked this pull request as ready for review January 27, 2026 08:18
@jquast jquast changed the title Bugfix grapheme and East-Asian support by wcwidth>=0.3.5 integration Bugfix grapheme and East-Asian support by wcwidth>=0.5.1 integration Jan 27, 2026
casted_cell = str(cell)
wrapped = [
"\n".join(wrapper.wrap(line))
"\n".join(wrapper_wrap(line))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functools.partial() was just used to help make this change clear and concise, not needed but doesn't hurt and already imported and used somewhere else

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.

1 participant