gtktext: Also reset IM context after IM surrounding text deletion
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 6 Sep 2022 19:53:25 +0000 (21:53 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 6 Sep 2022 20:17:40 +0000 (22:17 +0200)
When the IM commands the GtkText to delete text, the cursor position
would change, and so would the surrounding text. Reset the IM context
so that these updates are properly picked up by the IM.

Fixes backspace key behavior in the GNOME Shell OSK, since that relies
on the surrounding text being properly updated for the next iteration.

gtk/gtktext.c

index 5fbc3e95fef0c5a79a3d8503d11458854be8fe84..796683e44e3cf9972b1d01ff07a244d410a53b81 100644 (file)
@@ -4298,9 +4298,12 @@ gtk_text_delete_surrounding_cb (GtkIMContext *context,
   GtkTextPrivate *priv = gtk_text_get_instance_private (self);
 
   if (priv->editable)
-    gtk_editable_delete_text (GTK_EDITABLE (self),
-                              priv->current_pos + offset,
-                              priv->current_pos + offset + n_chars);
+    {
+      gtk_editable_delete_text (GTK_EDITABLE (self),
+                                priv->current_pos + offset,
+                                priv->current_pos + offset + n_chars);
+      gtk_im_context_reset (context);
+    }
 
   return TRUE;
 }