Skip to content

Fix table formatter width for arrows and rare wide characters - #1581

Open
seeones wants to merge 1 commit into
yzhang-gh:masterfrom
seeones:fix/table-formatter-wide-chars
Open

Fix table formatter width for arrows and rare wide characters#1581
seeones wants to merge 1 commit into
yzhang-gh:masterfrom
seeones:fix/table-formatter-wide-chars

Conversation

@seeones

@seeones seeones commented Aug 5, 2026

Copy link
Copy Markdown

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: extend doubleWidthRegex to 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 --build passes; the new case's expected output was verified against the formatter implementation.
  • Note: in my local environment the pre-existing Table formatter integration 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:

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.
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