gtktextview: Also reset IM context after IM surrounding text deletion
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 6 Sep 2022 19:55:13 +0000 (21:55 +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/gtktextview.c

index 1684b3288ef8ab389a0c667253d8d9d908871ebf..2e600e01bb92c52ca3c9f0c9d1c43af3eab965c0 100644 (file)
@@ -8695,8 +8695,9 @@ gtk_text_view_delete_surrounding_handler (GtkIMContext  *context,
   gtk_text_iter_forward_chars (&start, offset);
   gtk_text_iter_forward_chars (&end, offset + n_chars);
 
-  gtk_text_buffer_delete_interactive (priv->buffer, &start, &end,
-                                     priv->editable);
+  if (gtk_text_buffer_delete_interactive (priv->buffer, &start, &end,
+                                          priv->editable))
+    gtk_im_context_reset (context);
 
   return TRUE;
 }