refactor(width): delegate CJK classification to xterm wcwidth table#76
Open
KoalaHao wants to merge 1 commit into
Open
refactor(width): delegate CJK classification to xterm wcwidth table#76KoalaHao wants to merge 1 commit into
KoalaHao wants to merge 1 commit into
Conversation
Replaces the hand-maintained range whitelist in _isWideCharacter with a single call to the Unicode 11 wcwidth table already vendored at lib/src/third_party/xterm_pure.dart/src/utils/unicode_v11.dart. Verified via probe that the table returns 2 for every range the whitelist covered (CJK ideographs, kana, hangul, fullwidth, CJK Symbols and Punctuation 《, 》, 「, 」, ...). Three small layers stay manual: * Tab -> 1 column (table returns 0) * Zero-width characters (combining marks, ZWJ, variation selectors) -> 0, regardless of what the table says * General Punctuation 0x2010-0x205F -> 2 columns. The table returns 1 for these (East Asian Ambiguous), but CJK text renders em dash, smart quotes, ellipsis, primes, and reversed question/exclamation marks as full-width. * Emoji allowlist (regional indicators, certain Dingbats/Misc Symbols) bumps width-1 emoji to 2 when the table classifies them as Narrow/Neutral. Removes the maintenance burden of hand-tracking Unicode ranges. A new CJK block added in a future Unicode revision is covered automatically, with no edits to this file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the hand-maintained range whitelist in _isWideCharacter with a single call to the Unicode 11 wcwidth table already vendored at lib/src/third_party/xterm_pure.dart/src/utils/unicode_v11.dart. Verified via probe that the table returns 2 for every range the whitelist covered (CJK ideographs, kana, hangul, fullwidth, CJK Symbols and Punctuation 《, 》, 「, 」, ...).
Three small layers stay manual:
Removes the maintenance burden of hand-tracking Unicode ranges. A new CJK block added in a future Unicode revision is covered automatically, with no edits to this file.