diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2025-02-06 06:31:30 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-02-06 06:37:55 +0000 |
| commit | 88dcde3ed8b30c14a5d834d0e88f9b4a5f584939 (patch) | |
| tree | dadd0006f33982832580ea1b40dbf538106b153e /vt.c | |
| parent | Merge branch 'regex-mode' (diff) | |
term: insert-mode: handle combining characters correctly
When the client application emits combining characters, for example
multi-codepoint emojis, in insert-mode, we ended up pushing partial
graphemes to the right, for each codepoint, resulting in too many
cells (and with the wrong content) being inserted.
The fix is fairly simple; don't "insert" when appending characters to
an existing grapheme cluster.
This isn't something we can detect easily in print_insert() (it would
require us to do grapheme clustering again). Fortunately, we do have
the required information in action_utf8_print(). So, pass this
information as a boolean to term_print().
Closes #1947
Diffstat (limited to 'vt.c')
| -rw-r--r-- | vt.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -703,6 +703,7 @@ static void action_utf8_print(struct terminal *term, char32_t wc) { int width = c32width(wc); + bool insert_mode_disable = false; const bool grapheme_clustering = term->grapheme_shaping; #if !defined(FOOT_GRAPHEME_CLUSTERING) @@ -757,6 +758,7 @@ action_utf8_print(struct terminal *term, char32_t wc) if (base_width > 0) { term->grid->cursor.point.col = col; term->grid->cursor.lcf = false; + insert_mode_disable = true; if (composed == NULL) { bool base_from_primary; @@ -954,7 +956,7 @@ action_utf8_print(struct terminal *term, char32_t wc) out: if (width > 0) - term_print(term, wc, width); + term_print(term, wc, width, insert_mode_disable); } static void |
