Commit bcbdc86
committed
fix(tables): measure columns by terminal cell width, not code units
`displayWidth` used `stripAnsi(text).length`, which counts UTF-16 code
units instead of rendered terminal cells. Full-width CJK, emoji, and
combined-code-point glyphs each reported width 1–2 code units even when
the terminal renders them as 2 columns, and surrogate pairs (non-BMP
emoji) were double-counted as 2 for a single glyph. Columns containing
such values misaligned in both `formatSimpleTable` and `formatTable`.
Routes the measurement through `stringWidth` (Intl.Segmenter + East
Asian Width), which already strips ANSI and reports actual cell counts.1 parent 6781565 commit bcbdc86
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
0 commit comments