Commit graph

2 commits

Author SHA1 Message Date
Alex
cd0667136d fix(code_editor): honour East Asian Wide width in column_count (#1048)
`CharExt::column_count` was hard-coded to return 1 for every char. The
code editor's layouter advances x-position by this value per grapheme
(see `code_editor.rs:1217`), so CJK glyphs — which the text shaper draws
at ~2× the Latin monospace advance — overlap one another. Cursor
placement, selection rectangles, and wrap points suffer the same
off-by-half because they all read from `column_count`.

Match the Unicode East Asian Width property so Wide and Fullwidth
characters (plus common emoji that render at double-width) report 2
columns. Keeps a small literal match table instead of pulling in the
\`unicode-width\` crate, since only broad blocks are needed and perf on
the layout hot path matters.

Ranges covered:
  U+3000..U+30FF   CJK punctuation / Hiragana / Katakana
  U+3400..U+4DBF   CJK Unified Ideographs Extension A
  U+4E00..U+9FFF   CJK Unified Ideographs
  U+AC00..U+D7AF   Hangul Syllables
  U+F900..U+FAFF   CJK Compatibility Ideographs
  U+FF00..U+FF60   Fullwidth forms
  U+FFE0..U+FFE6   Fullwidth sign forms
  U+20000..U+2FFFF CJK Unified Ideographs Extensions B..F
  U+1F300..U+1F9FF Emoticons / symbols / transport / supplemental

Effect: Chinese/Japanese/Korean/emoji in code blocks render with correct
spacing in CodeView (and in any widget that layouts via CodeSession).
Latin-only workflows are unaffected.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 22:00:54 +02:00
Eddy Bruel
ff9048cc37 Initial commit 2025-05-06 10:11:37 +02:00