aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2024-03-09 09:02:04 +1100
committerNeil <nyamatongwe@gmail.com>2024-03-09 09:02:04 +1100
commitfe074f193e72d030447b96a231846a24b17a41ac (patch)
tree3a6418a63dd4047b3f1d45e6db437f82699a45e3 /test
parent212219da82d0a430dbf4eac1528056440f07940c (diff)
downloadscintilla-mirror-fe074f193e72d030447b96a231846a24b17a41ac.tar.gz
Bug [#2432]. Fix redo failure.
Diffstat (limited to 'test')
-rw-r--r--test/unit/testCellBuffer.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/testCellBuffer.cxx b/test/unit/testCellBuffer.cxx
index a6bd5dba1..acd21d32e 100644
--- a/test/unit/testCellBuffer.cxx
+++ b/test/unit/testCellBuffer.cxx
@@ -397,6 +397,32 @@ TEST_CASE("UndoHistory") {
REQUIRE(!uh.IsSavePoint());
}
+ SECTION("EnsureTruncationAfterUndo") {
+
+ REQUIRE(uh.Actions() == 0);
+ bool startSequence = false;
+ uh.AppendAction(ActionType::insert, 0, "ab", 2, startSequence, true);
+ REQUIRE(uh.Actions() == 1);
+ uh.AppendAction(ActionType::insert, 2, "cd", 2, startSequence, true);
+ REQUIRE(uh.Actions() == 2);
+ REQUIRE(uh.CanUndo());
+ REQUIRE(!uh.CanRedo());
+
+ // Undoing
+ const int steps = uh.StartUndo();
+ REQUIRE(steps == 2);
+ uh.GetUndoStep();
+ uh.CompletedUndoStep();
+ REQUIRE(uh.Actions() == 2); // Not truncated until forward action
+ uh.GetUndoStep();
+ uh.CompletedUndoStep();
+ REQUIRE(uh.Actions() == 2);
+
+ // Perform action which should truncate history
+ uh.AppendAction(ActionType::insert, 0, "12", 2, startSequence, true);
+ REQUIRE(uh.Actions() == 1);
+ }
+
SECTION("Coalesce") {
bool startSequence = false;