[gtk/gtk-4-4] texthistory: add barriers after final grouping
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-4] texthistory: add barriers after final grouping
- Date: Fri, 24 Sep 2021 23:38:08 +0000 (UTC)
commit f8cd883e0d694009851368ce7613bba4dc5d93fe
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 22 17:08:02 2021 -0700
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
gtk/gtktexthistory.c | 6 ++++++
testsuite/gtk/texthistory.c | 18 ++++++++++++++++++
2 files changed, 24 insertions(+)
---
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 c64c803083..505e6d7893 100644
--- a/testsuite/gtk/texthistory.c
+++ b/testsuite/gtk/texthistory.c
@@ -604,6 +604,23 @@ test14 (void)
g_free (fill);
}
+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[])
@@ -624,6 +641,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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]