From a0b8f60ce79f93f37242a20d7b9a3e3b7ddc46a1 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 10 Jun 2023 09:57:41 +0800 Subject: [PATCH] Inherit surrounding text properties when inserting conversion text * src/textconv.c (really_commit_text) (really_set_composing_text): Improve behavior of certain fontification mechanisms by inheriting text properties from surrounding text. --- src/textconv.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/textconv.c b/src/textconv.c index 3303ca246de..d86877b5515 100644 --- a/src/textconv.c +++ b/src/textconv.c @@ -624,7 +624,13 @@ really_commit_text (struct frame *f, EMACS_INT position, if (SCHARS (text)) { - Finsert (1, &text); + /* Insert the new text. Make sure to inherit text + properties from the surroundings: if this doesn't happen, + CC Mode fontification can get thrown off and become very + slow. */ + + insert_from_string (text, 0, 0, SCHARS (text), + SBYTES (text), true); record_buffer_change (start, PT, text); } @@ -686,7 +692,14 @@ really_commit_text (struct frame *f, EMACS_INT position, if (SCHARS (text)) { - Finsert (1, &text); + /* Insert the new text. Make sure to inherit text + properties from the surroundings: if this doesn't happen, + CC Mode fontification can get thrown off and become very + slow. */ + + insert_from_string (text, 0, 0, SCHARS (text), + SBYTES (text), true); + record_buffer_change (wanted, PT, text); } @@ -835,8 +848,12 @@ really_set_composing_text (struct frame *f, ptrdiff_t position, record_buffer_change (start, start, Qt); } - /* Insert the new text. */ - Finsert (1, &text); + /* Insert the new text. Make sure to inherit text properties from + the surroundings: if this doesn't happen, CC Mode fontification + can get thrown off and become very slow. */ + + insert_from_string (text, 0, 0, SCHARS (text), + SBYTES (text), true); if (start != PT) record_buffer_change (start, PT, Qt); -- 2.39.2