[mutter/wip/carlosg/input-method-fixes: 1/5] clutter: Fix ClutterText ::delete-surrounding IM implementation




commit 9d1488579ee24d92f1dc93a94a157cd88afe5346
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Apr 22 17:56:00 2022 +0200

    clutter: Fix ClutterText ::delete-surrounding IM implementation
    
    The clutter_text_delete_text() function used underneath expects character
    offsets for both start/end position. Fix the end position passed an offset
    instead of that, and compesnate for the cursor position being always -1
    when the caret is at the end of the string.

 clutter/clutter/clutter-text.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 432ddbae66..a5ecd8939b 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -356,10 +356,16 @@ clutter_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
                                              guint              len)
 {
   ClutterText *clutter_text = CLUTTER_TEXT_INPUT_FOCUS (focus)->text;
+  ClutterTextBuffer *buffer;
   int cursor;
   int start;
 
+  buffer = clutter_text_get_buffer (clutter_text);
+
   cursor = clutter_text_get_cursor_position (clutter_text);
+  if (cursor < 0)
+    cursor = clutter_text_buffer_get_length (buffer);
+
   start = cursor + offset;
   if (start < 0)
     {
@@ -368,7 +374,7 @@ clutter_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
       return;
     }
   if (clutter_text_get_editable (clutter_text))
-    clutter_text_delete_text (clutter_text, start, len);
+    clutter_text_delete_text (clutter_text, start, start + len);
 }
 
 static void


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