emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android a0b8f60ce79: Inherit surrounding text properties when in


From: Po Lu
Subject: feature/android a0b8f60ce79: Inherit surrounding text properties when inserting conversion text
Date: Fri, 9 Jun 2023 21:58:03 -0400 (EDT)

branch: feature/android
commit a0b8f60ce79f93f37242a20d7b9a3e3b7ddc46a1
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]