forked from qt-creator/qt-creator
fakevim: Correct cursor position after 'J'
Change-Id: Iff0c719c6b301dac333a55acfb073c7d1e1a27c8 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -2384,11 +2384,11 @@ void FakeVimPlugin::test_vim_command_J()
|
|||||||
|
|
||||||
KEYS("J", lmid(0, 5) + "| " + lmid(5));
|
KEYS("J", lmid(0, 5) + "| " + lmid(5));
|
||||||
KEYS("u", lmid(0, 4) + "\nint |main(int argc, char *argv[])\n" + 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("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));
|
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()
|
void FakeVimPlugin::test_vim_command_put_at_eol()
|
||||||
|
|||||||
@@ -3461,13 +3461,12 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
|
|||||||
} else if (input.isControl('i')) {
|
} else if (input.isControl('i')) {
|
||||||
jump(count());
|
jump(count());
|
||||||
} else if (input.is('J')) {
|
} else if (input.is('J')) {
|
||||||
|
setUndoPosition();
|
||||||
moveBehindEndOfLine();
|
moveBehindEndOfLine();
|
||||||
const int pos = position();
|
|
||||||
beginEditBlock();
|
beginEditBlock();
|
||||||
if (m_submode == NoSubMode)
|
if (m_submode == NoSubMode)
|
||||||
joinLines(count(), m_gflag);
|
joinLines(count(), m_gflag);
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
setPosition(pos);
|
|
||||||
setDotCommand("%1J", count());
|
setDotCommand("%1J", count());
|
||||||
} else if (input.isControl('l')) {
|
} else if (input.isControl('l')) {
|
||||||
// screen redraw. should not be needed
|
// screen redraw. should not be needed
|
||||||
@@ -6204,8 +6203,11 @@ void FakeVimHandler::Private::pasteText(bool afterCursor)
|
|||||||
|
|
||||||
void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
|
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();
|
moveBehindEndOfLine();
|
||||||
|
pos = position();
|
||||||
setAnchor();
|
setAnchor();
|
||||||
moveRight();
|
moveRight();
|
||||||
if (preserveSpace) {
|
if (preserveSpace) {
|
||||||
@@ -6216,6 +6218,7 @@ void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
|
|||||||
cursor().insertText(QString(QLatin1Char(' ')));
|
cursor().insertText(QString(QLatin1Char(' ')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FakeVimHandler::Private::lineContents(int line) const
|
QString FakeVimHandler::Private::lineContents(int line) const
|
||||||
|
|||||||
Reference in New Issue
Block a user