Commit ece5a4a3 authored by Lukas Holecek's avatar Lukas Holecek Committed by hjk
Browse files

fakevim: Merge marks on undo so new marks are not lost

Overwriting a mark with new position and undoing restores the previous
state of the mark.

Creating new mark (not overwriting old value) on a position and undoing
won't remove the mark.

Change-Id: I673874ef9df0aae16f86efe8599a43a77aae19ee
Reviewed-by: default avatarhjk <>
parent 9ed83d4e
......@@ -1151,6 +1151,19 @@ void FakeVimPlugin::test_vim_marks()
KEYS("''", " " "abc" N " " X "def" N " " "ghi");
KEYS("`'", X " " "abc" N " " "def" N " " "ghi");
KEYS("`'", " " "abc" N " " X "def" N " " "ghi");
// new mark isn't lost on undo
data.setText( "abc" N "d" X "ef" N "ghi");
KEYS("x" "mx" "gg", X "abc" N "df" N "ghi");
KEYS("ugg" "`x", "abc" N "d" X "ef" N "ghi");
// previous value of mark is restored on undo/redo
data.setText( "abc" N "d" X "ef" N "ghi");
KEYS("mx" "x" "ggl", "a" X "bc" N "df" N "ghi");
KEYS("mx" "uG" "`x", "abc" N "d" X "ef" N "ghi");
KEYS("<c-r>G" "`x", "a" X "bc" N "df" N "ghi");
KEYS("uG" "`x", "abc" N "d" X "ef" N "ghi");
KEYS("<c-r>G" "`x", "a" X "bc" N "df" N "ghi");
void FakeVimPlugin::test_vim_jumps()
......@@ -1690,6 +1690,8 @@ public:
void setMark(QChar code, CursorPosition position);
// jump to valid mark return true if mark is valid and local
bool jumpToMark(QChar mark, bool backTickMode);
// update marks on undo/redo
void updateMarks(const Marks &newMarks);
Marks m_marks; // local marks
// vi style configuration
......@@ -6483,7 +6485,9 @@ void FakeVimHandler::Private::undoRedo(bool undo)
State &state =;
if (state.revision == rev) {
m_lastChangePosition = state.position;
m_marks = state.marks;
Marks marks = m_marks;
m_lastVisualMode = state.lastVisualMode;
setMark('\'', lastPos);
......@@ -6926,6 +6930,14 @@ bool FakeVimHandler::Private::jumpToMark(QChar mark, bool backTickMode)
return true;
void FakeVimHandler::Private::updateMarks(const Marks &newMarks)
for (MarksIterator it(newMarks); it.hasNext(); ) {;
m_marks[it.key()] = it.value();
RangeMode FakeVimHandler::Private::registerRangeMode(int reg) const
bool isClipboard;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment