Commit 1731e9c
refactor: optimize Unicode width calculation based on iblea feedback
Per iblea's suggestion in PR #563, added comprehensive Korean and Japanese
character detection with checkAsianCharacter() helper function covering:
- Korean Hangul (unicode.Hangul)
- Korean Jamo ranges (0x1100-0x11FF, 0x3130-0x318F)
- Japanese Hiragana and Katakana (unicode.Hiragana, unicode.Katakana)
- Enclosed CJK Letters (0x3200-0x32FF)
Key insight discovered during implementation:
ansi.StringWidth already handles CJK characters correctly, so we only
need the runewidth fallback for emoji and special symbols. This keeps
table rendering consistent while improving emoji support.
Changes:
- Simplified stringWidth() to always use fallback for emoji
- Removed CJK from containsComplexUnicode() detection
- Updated tests to reflect that CJK is handled by ansi.StringWidth
- All tests pass including table width constraints
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent efa8a08 commit 1731e9c
2 files changed
+13
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 53 | + | |
58 | 54 | | |
59 | | - | |
| 55 | + | |
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
| |||
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
80 | | - | |
| 76 | + | |
81 | 77 | | |
82 | 78 | | |
83 | 79 | | |
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
87 | | - | |
88 | | - | |
| 83 | + | |
89 | 84 | | |
90 | 85 | | |
91 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
0 commit comments