diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 9907ce5c36a..50385d9c6ac 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -50,6 +50,7 @@ #include + #include #include #include @@ -2049,6 +2050,14 @@ void FakeVimHandler::Private::moveToTargetColumn() } } +/* if simple is given: + * class 0: spaces + * class 1: non-spaces + * else + * class 0: spaces + * class 1: non-space-or-letter-or-number + * class 2: letter-or-number + */ static int charClass(QChar c, bool simple) { if (simple) @@ -2066,6 +2075,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward) int lastClass = -1; while (true) { QChar c = doc->characterAt(m_tc.position() + (forward ? 1 : -1)); + qDebug() << "EXAMINING: " << c << " AT " << position(); int thisClass = charClass(c, simple); if (thisClass != lastClass && lastClass != 0) --repeat; @@ -2076,6 +2086,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward) break; forward ? moveRight() : moveLeft(); } + setTargetColumn(); } void FakeVimHandler::Private::handleFfTt(int key) @@ -2111,6 +2122,7 @@ void FakeVimHandler::Private::handleFfTt(int key) break; } } + setTargetColumn(); } void FakeVimHandler::Private::moveToNextWord(bool simple) @@ -2131,6 +2143,7 @@ void FakeVimHandler::Private::moveToNextWord(bool simple) if (m_tc.position() == n) break; } + setTargetColumn(); } void FakeVimHandler::Private::moveToMatchingParanthesis() @@ -2144,6 +2157,7 @@ void FakeVimHandler::Private::moveToMatchingParanthesis() if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) m_tc.movePosition(Left, KeepAnchor, 1); } + setTargetColumn(); } int FakeVimHandler::Private::cursorLineOnScreen() const diff --git a/tests/auto/fakevim/main.cpp b/tests/auto/fakevim/main.cpp index 9003da818c1..a1ac3be7826 100644 --- a/tests/auto/fakevim/main.cpp +++ b/tests/auto/fakevim/main.cpp @@ -55,10 +55,13 @@ public slots: void changeExtraInformation(const QString &info) { m_infoMessage = info; } private slots: - void commandI(); void commandDollar(); void commandDown(); + void commandLeft(); + void commandRight(); + void commandI(); void commandUp(); + void commandW(); private: void setup(); @@ -203,6 +206,10 @@ bool tst_FakeVim::checkHelper(bool ex, QString cmd, QString expected, do { if (!checkHelper(false, cmd, expected, __FILE__, __LINE__)) \ return; } while (0) +#define move(cmd, expected) \ + do { if (!checkHelper(false, cmd, insertCursor(expected), __FILE__, __LINE__)) \ + return; } while (0) + // Runs an ex command and checks the result. // Cursor position is marked by a '@' in the expected contents. #define checkEx(cmd, expected) \ @@ -235,7 +242,7 @@ void tst_FakeVim::commandI() check("ixxx" + escape, "xx@x" + lines); check("u", "@" + lines); - return; +return; // combine insertions check("ia" + escape, "@a" + lines); @@ -251,27 +258,57 @@ void tst_FakeVim::commandI() void tst_FakeVim::commandDollar() { setup(); - check("j$", insertCursor("@")); - check("j$", insertCursor("@")); - check("2j", insertCursor(")@")); + move("j$", "@"); + move("j$", "@"); + move("2j", ")@"); } void tst_FakeVim::commandDown() { setup(); - check("j", insertCursor("@#include #include