summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2021-09-22 17:08:02 -0700
committerChristian Hergert <chergert@redhat.com>2021-09-23 13:25:35 -0700
commitb578c78eff41bd2dbedf459a102e05eec78b7f7c (patch)
tree8f1a495a83577a63d1b25a33d24da98d999c10cd
parentd7db3f1546156f406509e5bfbf076cd575c5628d (diff)
downloadgtk+-b578c78eff41bd2dbedf459a102e05eec78b7f7c.tar.gz
texthistory: add barriers after final grouping
We don't want to allow new items to be grouped into a previous action group after the end_user_action() is called. This ensures that we add a barrier action in those conditions. Fixes #4276
-rw-r--r--gtk/gtktexthistory.c6
-rw-r--r--testsuite/gtk/texthistory.c18
2 files changed, 24 insertions, 0 deletions
diff --git a/gtk/gtktexthistory.c b/gtk/gtktexthistory.c
index 61ccc33f08..3b9379ccc3 100644
--- a/gtk/gtktexthistory.c
+++ b/gtk/gtktexthistory.c
@@ -224,6 +224,12 @@ action_chain (Action *action,
if (other->kind == ACTION_KIND_BARRIER)
{
+ /* If we're not in a user action, this barrier is meant to
+ * stop items from coallescing into this group.
+ */
+ if (!in_user_action && action->u.group.depth == 0)
+ return FALSE;
+
action_free (other);
return TRUE;
}
diff --git a/testsuite/gtk/texthistory.c b/testsuite/gtk/texthistory.c
index cca4008196..a740d3523b 100644
--- a/testsuite/gtk/texthistory.c
+++ b/testsuite/gtk/texthistory.c
@@ -606,6 +606,23 @@ test14 (void)
g_free (fill_after_2);
}
+static void
+test_issue_4276 (void)
+{
+ const Command commands[] = {
+ { INSERT, 0, -1, "this is some text", "this is some text", SET, UNSET, UNSET },
+ { SELECT, 0, 17, NULL, "this is some text", SET, UNSET, UNSET },
+ { BEGIN_USER, -1, -1, NULL, NULL, UNSET, UNSET, UNSET },
+ { DELETE_KEY, 0, 17, "this is some text", "", UNSET, UNSET, UNSET },
+ { INSERT, 0, -1, "z", "z", UNSET, UNSET, UNSET },
+ { END_USER, -1, -1, NULL, NULL, SET, UNSET, UNSET },
+ { INSERT, 1, -1, "zzz", "zzzz", SET, UNSET, UNSET },
+ { UNDO, -1, -1, NULL, "z", SET, SET, UNSET },
+ };
+
+ run_test (commands, G_N_ELEMENTS (commands), 0);
+}
+
int
main (int argc,
char *argv[])
@@ -626,6 +643,7 @@ main (int argc,
g_test_add_func ("/Gtk/TextHistory/test12", test12);
g_test_add_func ("/Gtk/TextHistory/test13", test13);
g_test_add_func ("/Gtk/TextHistory/test14", test14);
+ g_test_add_func ("/Gtk/TextHistory/issue_4276", test_issue_4276);
return g_test_run ();
}