[mutter/wip/carlosg/input-method-fixes: 2/6] clutter: Fix ClutterText ::delete-surrounding IM implementation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-method-fixes: 2/6] clutter: Fix ClutterText ::delete-surrounding IM implementation
- Date: Sat, 23 Apr 2022 13:05:57 +0000 (UTC)
commit f81a37b1e3993d9429008fa212afa62ccc0fcfee
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..5ca5fa4a2c 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 = 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]