From 4c80a1ab9295caa714a78490a52c31bc103901ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Aum=C3=BCller?= <aumuell@reserv.at> Date: Fri, 19 Feb 2010 13:01:37 +0100 Subject: [PATCH] fakevim: dfx should do nothing if no x is found Merge-request: 113 Reviewed-by: hjk <qtc-committer@nokia.com> --- src/plugins/fakevim/fakevimhandler.cpp | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 06ce0c71bb2..a2f9e7c2956 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -378,7 +378,7 @@ public: void setAnchor(int position) { if (!isVisualMode()) m_anchor = position; } void setPosition(int position) { m_tc.setPosition(position, MoveAnchor); } - void handleFfTt(int key); + bool handleFfTt(int key); // helper function for handleExCommand. return 1 based line index. int readLineCode(QString &cmd); @@ -1222,12 +1222,17 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, } else if (m_subsubmode == FtSubSubMode) { m_semicolonType = m_subsubdata; m_semicolonKey = key; - handleFfTt(key); + bool valid = handleFfTt(key); m_subsubmode = NoSubSubMode; - finishMovement(QString("%1%2%3") - .arg(count()) - .arg(QChar(m_semicolonType)) - .arg(QChar(m_semicolonKey))); + if (!valid) { + m_submode = NoSubMode; + finishMovement(); + } else { + finishMovement(QString("%1%2%3") + .arg(count()) + .arg(QChar(m_semicolonType)) + .arg(QChar(m_semicolonKey))); + } } else if (m_submode == ReplaceSubMode) { if (count() <= (rightDist() + atEndOfLine()) && text.size() == 1 && (text.at(0).isPrint() || text.at(0).isSpace())) { @@ -2806,8 +2811,9 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward, bool setTargetColumn(); } -void FakeVimHandler::Private::handleFfTt(int key) +bool FakeVimHandler::Private::handleFfTt(int key) { + int oldPos = position(); // m_subsubmode \in { 'f', 'F', 't', 'T' } bool forward = m_subsubdata == 'f' || m_subsubdata == 't'; int repeat = count(); @@ -2839,7 +2845,13 @@ void FakeVimHandler::Private::handleFfTt(int key) break; } } - setTargetColumn(); + if (repeat == 0) { + setTargetColumn(); + return true; + } else { + setPosition(oldPos); + return false; + } } void FakeVimHandler::Private::moveToNextWord(bool simple, bool deleteWord) -- GitLab