summaryrefslogtreecommitdiff
path: root/gtk/gtktext.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-10-18 23:37:03 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-10-18 23:49:16 -0400
commit1e5e0480fddfef1104ffc343943d3f32efb2f1bb (patch)
treec5147b88852f54a8daa2af2d1d70a6ee1ce3ede9 /gtk/gtktext.c
parentf658027c51a99dfb99b0a2bbe3dbfa8cd6ed0900 (diff)
downloadgtk+-1e5e0480fddfef1104ffc343943d3f32efb2f1bb.tar.gz
text: Make overwrite undo-friendly
In overwrite mode, every typed character gets handled as a delete+insert, but we should not record these as two individually undoable steps. This matches how we handle overwrite mode in GtkTextView. Fixes: #4411
Diffstat (limited to 'gtk/gtktext.c')
-rw-r--r--gtk/gtktext.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index d67b57825c..39eda89baa 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -4321,6 +4321,9 @@ gtk_text_enter_text (GtkText *self,
int tmp_pos;
guint text_length;
+ gtk_text_history_begin_user_action (priv->history);
+ begin_change (self);
+
priv->need_im_reset = FALSE;
if (priv->selection_bound != priv->current_pos)
@@ -4338,6 +4341,9 @@ gtk_text_enter_text (GtkText *self,
tmp_pos = priv->current_pos;
gtk_editable_insert_text (GTK_EDITABLE (self), str, strlen (str), &tmp_pos);
gtk_text_set_selection_bounds (self, tmp_pos, tmp_pos);
+
+ end_change (self);
+ gtk_text_history_end_user_action (priv->history);
}
/* All changes to priv->current_pos and priv->selection_bound