Commit a99874c0 authored by Lukas Holecek's avatar Lukas Holecek Committed by hjk

fakevim: Correct cursor position after 'J'

Change-Id: Iff0c719c6b301dac333a55acfb073c7d1e1a27c8
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 477285b9
......@@ -2384,11 +2384,11 @@ void FakeVimPlugin::test_vim_command_J()
KEYS("J", lmid(0, 5) + "| " + lmid(5));
KEYS("u", lmid(0, 4) + "\nint |main(int argc, char *argv[])\n" + lmid(5));
COMMAND("redo", lmid(0, 5) + "| " + lmid(5));
COMMAND("redo", lmid(0, 4) + "\nint |main(int argc, char *argv[]) " + lmid(5));
KEYS("3J", lmid(0, 5) + " " + lmid(5, 1) + " " + lmid(6, 1).mid(4) + "| " + lmid(7));
KEYS("uu", lmid(0, 4) + "\nint |main(int argc, char *argv[])\n" + lmid(5));
COMMAND("redo", lmid(0, 5) + "| " + lmid(5));
COMMAND("redo", lmid(0, 4) + "\nint |main(int argc, char *argv[]) " + lmid(5));
}
void FakeVimPlugin::test_vim_command_put_at_eol()
......
......@@ -3461,13 +3461,12 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
} else if (input.isControl('i')) {
jump(count());
} else if (input.is('J')) {
setUndoPosition();
moveBehindEndOfLine();
const int pos = position();
beginEditBlock();
if (m_submode == NoSubMode)
joinLines(count(), m_gflag);
endEditBlock();
setPosition(pos);
setDotCommand("%1J", count());
} else if (input.isControl('l')) {
// screen redraw. should not be needed
......@@ -6204,8 +6203,11 @@ void FakeVimHandler::Private::pasteText(bool afterCursor)
void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
{
for (int i = qMax(count - 2, 0); i >= 0; --i) {
int pos = position();
const int blockNumber = cursor().blockNumber();
for (int i = qMax(count - 2, 0); i >= 0 && blockNumber < document()->blockCount(); --i) {
moveBehindEndOfLine();
pos = position();
setAnchor();
moveRight();
if (preserveSpace) {
......@@ -6216,6 +6218,7 @@ void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
cursor().insertText(QString(QLatin1Char(' ')));
}
}
setPosition(pos);
}
QString FakeVimHandler::Private::lineContents(int line) const
......
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