Commit 2a8a411b authored by hluk's avatar hluk Committed by hjk

FakeVim: Fixes and more tests for visual block mode

Task-number: QTCREATORBUG-9190
Change-Id: I4cc3ef675f65edafc1d68ae9dd1521656b5bfdb7
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent ed890bc9
......@@ -1082,6 +1082,41 @@ void FakeVimPlugin::test_vim_block_selection()
data.setText("\"abc" X "\"\"def\"");
KEYS("vi\"d", "\"" X "\"\"def\"");
/* QTCREATORBUG-9190 */
data.setText(" abcd" N " efgh" N " ijkl" N " mnop" N "");
data.doKeys("2lj" "<C-V>" "jl");
data.doKeys("x");
COMMAND("", " abcd" N " e" X "h" N " il" N " mnop" N "");
COMMAND(":undo", " abcd" N " e" X "fgh" N " ijkl" N " mnop" N "");
data.doKeys("<C-V>");
data.doKeys("j");
data.doKeys("l");
data.doKeys("x");
COMMAND("", " abcd" N " e" X "h" N " il" N " mnop" N "");
COMMAND(":undo", " abcd" N " e" X "fgh" N " ijkl" N " mnop" N "");
data.doKeys("gv");
data.doKeys("j");
data.doKeys("h");
data.doKeys("x");
COMMAND("", " abcd" N " e" X "gh" N " ikl" N " mop" N "");
COMMAND(":undo", " abcd" N " e" X "fgh" N " ijkl" N " mnop" N "");
data.doCommand("set passkeys");
data.doKeys("gv");
data.doKeys("k");
data.doKeys("l");
data.doKeys("r-");
COMMAND("", " abcd" N " e" X "--h" N " i--l" N " mnop" N "");
COMMAND(":undo", " abcd" N " e" X "fgh" N " ijkl" N " mnop" N "");
data.doKeys("gv");
data.doKeys("j");
data.doKeys("o");
data.doKeys("k");
data.doKeys("h");
data.doKeys("r9");
COMMAND("", " " X "999d" N " 999h" N " 999l" N " 999p" N "");
COMMAND(":undo", " " X "abcd" N " efgh" N " ijkl" N " mnop" N "");
data.doCommand("set nopasskeys");
// repeat change inner
data.setText("(abc)" N "def" N "(ghi)");
KEYS("ci(xyz<esc>", "(xy" X "z)" N "def" N "(ghi)");
......
......@@ -2236,6 +2236,7 @@ void FakeVimHandler::Private::exportSelection()
setAnchorAndPosition(anc, pos + 1);
if (m_visualMode == VisualBlockMode) {
commitCursor();
emit q->requestSetBlockSelection(false);
emit q->requestSetBlockSelection(true);
} else if (m_visualMode == VisualLineMode) {
......@@ -3934,6 +3935,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
setCursorPosition(m_lastVisualModeInverted ? to : from);
setAnchor();
setCursorPosition(m_lastVisualModeInverted ? from : to);
setTargetColumn();
}
} else if (input.is('v')) {
toggleVisualMode(VisualCharMode);
......@@ -6534,7 +6536,7 @@ void FakeVimHandler::Private::insertText(QTextCursor &tc, const QString &text)
passEventToEditor(event);
}
updateCursorShape();
tc = m_cursor;
m_cursor = oldTc;
} else {
tc.insertText(text);
......@@ -6794,8 +6796,11 @@ bool FakeVimHandler::Private::passEventToEditor(QEvent &event)
removeEventFilter();
commitCursor();
EDITOR(setOverwriteMode(false));
emit q->requestSetBlockSelection(false);
bool accepted = QApplication::sendEvent(editor(), &event);
updateCursorShape();
installEventFilter();
......
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