aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/UndoHistory.cxx2
-rw-r--r--test/unit/testCellBuffer.cxx26
3 files changed, 32 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index e3bc94835..93abf2670 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -591,6 +591,10 @@
Released 5 March 2024.
</li>
<li>
+ Fix redo failure introduced with 5.4.2.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2432/">Bug #2432</a>.
+ </li>
+ <li>
Add SC_AUTOCOMPLETE_SELECT_FIRST_ITEM option to
always selects the first item in the autocompletion list.
<a href="https://sourceforge.net/p/scintilla/bugs/2403/">Bug #2403</a>.
diff --git a/src/UndoHistory.cxx b/src/UndoHistory.cxx
index 66b6e62be..daae97ad5 100644
--- a/src/UndoHistory.cxx
+++ b/src/UndoHistory.cxx
@@ -315,6 +315,8 @@ const char *UndoHistory::AppendAction(ActionType at, Sci::Position position, con
const char *dataNew = lengthData ? scraps->Push(data, lengthData) : nullptr;
if (currentAction >= actions.SSize()) {
actions.PushBack();
+ } else {
+ actions.Truncate(currentAction+1);
}
actions.Create(currentAction, at, position, lengthData, mayCoalesce);
currentAction++;
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;