diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 3e515d3..5041ff6 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -4275,6 +4275,7 @@ gtk_text_view_move_visually
 gtk_text_view_new
 gtk_text_view_new_with_buffer
 gtk_text_view_place_cursor_onscreen
+gtk_text_view_reset_im_state
 gtk_text_view_scroll_mark_onscreen
 gtk_text_view_scroll_to_iter
 gtk_text_view_scroll_to_mark
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 80d356d..274c448 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -9201,5 +9201,28 @@ gtk_text_view_move_visually (GtkTextView *text_view,
   return gtk_text_layout_move_iter_visually (text_view->layout, iter, count);
 }
 
+/**
+ * gtk_text_view_reset_im_state:
+ * @text_view: a #GtkTextView
+ *
+ * Reset the input method state of the text view if needed.
+ *
+ * This can be necessary in the case where modifying the buffer
+ * would confuse on-going input method behavior.
+ *
+ * Since: 2.20
+ **/
+void
+gtk_text_view_reset_im_state (GtkTextView *text_view)
+{
+  g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+
+  if (text_view->need_im_reset)
+    {
+      text_view->need_im_reset = FALSE;
+      gtk_im_context_reset (text_view->im_context);
+    }
+}
+
 #define __GTK_TEXT_VIEW_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 2dfe23f..569e0bd 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -303,6 +303,7 @@ gboolean gtk_text_view_starts_display_line            (GtkTextView       *text_v
 gboolean gtk_text_view_move_visually                  (GtkTextView       *text_view,
                                                        GtkTextIter       *iter,
                                                        gint               count);
+void gtk_text_view_reset_im_state                     (GtkTextView       *text_view);
 
 /* Adding child widgets */
 void gtk_text_view_add_child_at_anchor (GtkTextView          *text_view,
