aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2014-01-20 17:39:05 (GMT)
committerMiquel Sabaté <mikisabate@gmail.com>2014-01-20 17:39:05 (GMT)
commit3539e7687b91de49f7d68b719d27b9f76e4d8379 (patch)
tree5424183eb62d1306ca6aa2b07b90702503a07185
parent55186a6b94135e60cb1ccf6064f26d352b90dce1 (diff)
vimode: fixed two crashes related to the undo/redo operations.
REVIEW: 115155
-rw-r--r--part/vimode/katevinormalmode.cpp11
-rw-r--r--tests/vimode_test.cpp17
2 files changed, 26 insertions, 2 deletions
diff --git a/part/vimode/katevinormalmode.cpp b/part/vimode/katevinormalmode.cpp
index 5bb20f4..a2bac52 100644
--- a/part/vimode/katevinormalmode.cpp
+++ b/part/vimode/katevinormalmode.cpp
@@ -1502,16 +1502,23 @@ bool KateViNormalMode::commandSearchForward()
bool KateViNormalMode::commandUndo()
{
+ // See BUG #328277
+ m_viInputModeManager->clearCurrentChangeLog();
+
+ if (doc()->undoCount() > 0) {
doc()->undo();
- // See BUG #328277
- m_viInputModeManager->clearCurrentChangeLog();
return true;
+ }
+ return false;
}
bool KateViNormalMode::commandRedo()
{
+ if (doc()->redoCount() > 0) {
doc()->redo();
return true;
+ }
+ return false;
}
bool KateViNormalMode::commandSetMark()
diff --git a/tests/vimode_test.cpp b/tests/vimode_test.cpp
index 335195c..fcd7735 100644
--- a/tests/vimode_test.cpp
+++ b/tests/vimode_test.cpp
@@ -7298,6 +7298,23 @@ void ViModeTest::MacroTests()
FinishTest("functionwithargs(firstArg)\nnoargfunction()\ncompletionA\ncompletionAtail\ncompletionB\nsemicolonfunctionwithargs(X);\nsemicolonfunctionnoargs();X");
}
+ // Check that undo/redo operations work properly with macros.
+ {
+ clearAllMacros();
+ BeginTest("");
+ TestPressKey("ihello\\ctrl-cqauq");
+ TestPressKey("@a\\enter");
+ FinishTest("");
+ }
+ {
+ clearAllMacros();
+ BeginTest("");
+ TestPressKey("ihello\\ctrl-cui.bye\\ctrl-cu");
+ TestPressKey("qa\\ctrl-r\\enterq");
+ TestPressKey("@a\\enter");
+ FinishTest(".bye");
+ }
+
// When replaying a last change in the process of replaying a macro, take the next completion
// event from the last change completions log, rather than the macro completions log.
// Ensure that the last change completions log is kept up to date even while we're replaying the macro.