Fix table formatter width for arrows and rare wide characters - #1581
Open
seeones wants to merge 1 commit into
Open
Fix table formatter width for arrows and rare wide characters#1581seeones wants to merge 1 commit into
seeones wants to merge 1 commit into
Conversation
Extend the double-width character class beyond emoji and common CJK ranges to cover the full UAX yzhang-gh#11 Wide/Fullwidth set (Hangul Jamo, CJK extensions and rare ideographs, vertical forms, fullwidth symbols) plus arrows (U+2190-U+21FF), which render double-width in CJK contexts. Adds a table formatting test with emoji, CJK, and arrow cells.
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.
Background
Since #1562, the table formatter computes a cell's visual width as grapheme count + double-width character count, but the double-width character class only covered
\p{Extended_Pictographic}plus a few common CJK ranges (U+3000–U+9FFF,U+AC00–U+D7AF,U+FF01–U+FF60). Tables containing other wide characters — most notably arrows such as↑ ↓ ← →(U+2190–U+21FF, rendered double-width in CJK contexts), but also rare CJK ideographs (Extension B and beyond) — end up misaligned after formatting.Changes
src/tableFormatter.ts: extenddoubleWidthRegexto the full UAX Support Chinese TOC #11 Wide/Fullwidth set — Hangul Jamo, CJK radicals & extensions, rare ideographs (U+20000–U+3FFFD), Yi, vertical forms, CJK compatibility forms, fullwidth forms/signs, and other supplementary wide blocks — plus arrows (U+2190–U+21FF), which are "Ambiguous" in UAX Support Chinese TOC #11 but render double-width in CJK fonts/terminals.src/test/suite/integration/tableFormatter.test.ts: add a "Wide symbols in table cells" case covering CJK text, emoji (✅/⬜) and arrow cells.No dependency, configuration, or behavior changes beyond column alignment.
Testing
tsc --buildpasses; the new case's expected output was verified against the formatter implementation.Table formatterintegration suite times out even on unmodified code (environment-specific; the other 286 tests pass), so the CI run is the authoritative one.Related
The same coverage gap existed in
markdownlint's MD060 (table-column-style), which uses the same width-calculation approach. A corresponding fix has been submitted there in parallel:fix/md060-wide-char-coverage)