From d7742d031276a19160dc9317ff6fb5aac861d853 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Jun 2026 15:34:12 +0200 Subject: term: do not allow codepoint merging into grapheme clusters directly after a cursor move That is, only do grapheme clustering when printing codepoints in sequence, without any cursor movements in between. Closes #2383 --- terminal.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 8eafbcbe..374d4371 100644 --- a/terminal.c +++ b/terminal.c @@ -4086,6 +4086,10 @@ term_print(struct terminal *term, char32_t wc, int width, bool insert_mode_disab xassert(!grid->cursor.lcf); grid->cursor.point.col = col; + +#if defined(FOOT_GRAPHEME_CLUSTERING) + term->vt.codepoint_merging_ok = true; +#endif } static void @@ -4126,6 +4130,9 @@ ascii_printer_fast(struct terminal *term, char32_t wc) xassert(!grid->cursor.lcf); grid->cursor.point.col = col; +#if defined(FOOT_GRAPHEME_CLUSTERING) + term->vt.codepoint_merging_ok = true; +#endif if (unlikely(row->extra != NULL)) { grid_row_uri_range_erase(row, uri_start, uri_start); @@ -4210,7 +4217,11 @@ term_process_and_print_non_ascii(struct terminal *term, char32_t wc) { int width = c32width(wc); bool insert_mode_disable = false; - const bool grapheme_clustering = term->grapheme_shaping; + const bool grapheme_clustering = term->grapheme_shaping +#if defined(FOOT_GRAPHEME_CLUSTERING) + && term->vt.codepoint_merging_ok +#endif + ; #if !defined(FOOT_GRAPHEME_CLUSTERING) xassert(!grapheme_clustering); -- cgit v1.3