From 0ff8f72a9d653269dd6127cc66322690c8a4b90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 25 Jun 2021 20:42:23 +0200 Subject: [PATCH] =?UTF-8?q?vt:=20don=E2=80=99t=20reset=20utf8proc=20graphe?= =?UTF-8?q?me=20state=20when=20we=E2=80=99re=20not=20at=20a=20grapheme=20b?= =?UTF-8?q?reak?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ vt.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01cf1fdc..3934dadf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,10 @@ ### Deprecated ### Removed ### Fixed + +* Grapheme cluster state being reset between codepoints. + + ### Security ### Contributors diff --git a/vt.c b/vt.c index ec011cad..900ffd9d 100644 --- a/vt.c +++ b/vt.c @@ -639,10 +639,10 @@ action_utf8_print(struct terminal *term, wchar_t wc) #if defined(FOOT_GRAPHEME_CLUSTERING) if (grapheme_clustering) { /* Check if we're on a grapheme cluster break */ - /* Note: utf8proc fails to ZWJ */ - if (utf8proc_grapheme_break_stateful(last, wc, &term->vt.grapheme_state) && - last != 0x200d /* ZWJ */) + if (utf8proc_grapheme_break_stateful( + last, wc, &term->vt.grapheme_state)) { + term_reset_grapheme_state(term); goto out; } } @@ -682,6 +682,7 @@ action_utf8_print(struct terminal *term, wchar_t wc) { wc = precomposed; width = precomposed_width; + term_reset_grapheme_state(term); goto out; } } @@ -746,6 +747,7 @@ action_utf8_print(struct terminal *term, wchar_t wc) * character chains. Fall through here and print the * current zero-width character to the current cell */ LOG_WARN("maximum number of composed characters reached"); + term_reset_grapheme_state(term); goto out; } @@ -780,10 +782,11 @@ action_utf8_print(struct terminal *term, wchar_t wc) xassert(wc <= CELL_COMB_CHARS_HI); goto out; } - } + } else + term_reset_grapheme_state(term); + out: - term_reset_grapheme_state(term); if (width > 0) term_print(term, wc, width); }