forked from qt-creator/qt-creator
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: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1151,6 +1151,19 @@ void FakeVimPlugin::test_vim_marks()
|
|||||||
KEYS("''", " " "abc" N " " X "def" N " " "ghi");
|
KEYS("''", " " "abc" N " " X "def" N " " "ghi");
|
||||||
KEYS("`'", X " " "abc" N " " "def" N " " "ghi");
|
KEYS("`'", X " " "abc" N " " "def" N " " "ghi");
|
||||||
KEYS("`'", " " "abc" N " " X "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()
|
void FakeVimPlugin::test_vim_jumps()
|
||||||
|
|||||||
@@ -1690,6 +1690,8 @@ public:
|
|||||||
void setMark(QChar code, CursorPosition position);
|
void setMark(QChar code, CursorPosition position);
|
||||||
// jump to valid mark return true if mark is valid and local
|
// jump to valid mark return true if mark is valid and local
|
||||||
bool jumpToMark(QChar mark, bool backTickMode);
|
bool jumpToMark(QChar mark, bool backTickMode);
|
||||||
|
// update marks on undo/redo
|
||||||
|
void updateMarks(const Marks &newMarks);
|
||||||
Marks m_marks; // local marks
|
Marks m_marks; // local marks
|
||||||
|
|
||||||
// vi style configuration
|
// vi style configuration
|
||||||
@@ -6483,7 +6485,9 @@ void FakeVimHandler::Private::undoRedo(bool undo)
|
|||||||
State &state = stack.top();
|
State &state = stack.top();
|
||||||
if (state.revision == rev) {
|
if (state.revision == rev) {
|
||||||
m_lastChangePosition = state.position;
|
m_lastChangePosition = state.position;
|
||||||
m_marks = state.marks;
|
Marks marks = m_marks;
|
||||||
|
marks.swap(state.marks);
|
||||||
|
updateMarks(marks);
|
||||||
m_lastVisualMode = state.lastVisualMode;
|
m_lastVisualMode = state.lastVisualMode;
|
||||||
setMark('\'', lastPos);
|
setMark('\'', lastPos);
|
||||||
setCursorPosition(m_lastChangePosition);
|
setCursorPosition(m_lastChangePosition);
|
||||||
@@ -6926,6 +6930,14 @@ bool FakeVimHandler::Private::jumpToMark(QChar mark, bool backTickMode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::updateMarks(const Marks &newMarks)
|
||||||
|
{
|
||||||
|
for (MarksIterator it(newMarks); it.hasNext(); ) {
|
||||||
|
it.next();
|
||||||
|
m_marks[it.key()] = it.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RangeMode FakeVimHandler::Private::registerRangeMode(int reg) const
|
RangeMode FakeVimHandler::Private::registerRangeMode(int reg) const
|
||||||
{
|
{
|
||||||
bool isClipboard;
|
bool isClipboard;
|
||||||
|
|||||||
Reference in New Issue
Block a user