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

fakevim: Correct cursor position after yank



Change-Id: I845eeebe44ed859cc96d69fbd660fce56cc1418b
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 611be1ae
......@@ -1205,6 +1205,12 @@ void FakeVimPlugin::test_vim_copy_paste()
data.setText("abc");
KEYS("yyp", "abc" N X "abc");
KEYS("4p", "abc" N "abc" N X "abc" N "abc" N "abc" N "abc");
// cursor position after yank
data.setText("ab" X "c" N "def");
KEYS("Vjy", X "abc" N "def");
data.setText("ab" X "c" N "def");
KEYS("<c-v>jhhy", X "abc" N "def");
}
void FakeVimPlugin::test_vim_undo_redo()
......
......@@ -2605,10 +2605,18 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement)
setTargetColumn();
endEditBlock();
} else if (m_submode == YankSubMode) {
setPosition(qMin(position(), anchor()));
const QTextCursor tc = cursor();
if (m_rangemode == RangeBlockMode) {
const int pos1 = tc.block().position();
const int pos2 = document()->findBlock(tc.anchor()).position();
const int col = qMin(tc.position() - pos1, tc.anchor() - pos2);
setPosition(qMin(pos1, pos2) + col);
} else {
setPosition(qMin(position(), anchor()));
if (m_rangemode == RangeLineMode)
moveToStartOfLine();
}
leaveVisualMode();
if (anchor() <= position())
setPosition(anchor());
} else if (m_submode == InvertCaseSubMode
|| m_submode == UpCaseSubMode
|| m_submode == DownCaseSubMode) {
......
Markdown is supported
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