fakevim: fix 'dw' at line-end

Merge-request: 99
Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
Martin Aumüller
2010-01-21 17:38:30 +01:00
committed by hjk
parent 2df1def883
commit 978fa5d03d
2 changed files with 12 additions and 8 deletions

View File

@@ -347,7 +347,7 @@ public:
m_targetColumn = leftDist(); m_targetColumn = leftDist();
//qDebug() << "TARGET: " << m_targetColumn; //qDebug() << "TARGET: " << m_targetColumn;
} }
void moveToNextWord(bool simple); void moveToNextWord(bool simple, bool deleteWord = false);
void moveToMatchingParanthesis(); void moveToMatchingParanthesis();
void moveToWordBoundary(bool simple, bool forward, bool changeWord = false); void moveToWordBoundary(bool simple, bool forward, bool changeWord = false);
@@ -1701,7 +1701,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveToWordBoundary(false, true, true); moveToWordBoundary(false, true, true);
m_movetype = MoveInclusive; m_movetype = MoveInclusive;
} else { } else {
moveToNextWord(false); moveToNextWord(false, m_submode==DeleteSubMode);
m_movetype = MoveExclusive; m_movetype = MoveExclusive;
} }
finishMovement("%1w", count()); finishMovement("%1w", count());
@@ -1710,7 +1710,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveToWordBoundary(true, true, true); moveToWordBoundary(true, true, true);
m_movetype = MoveInclusive; m_movetype = MoveInclusive;
} else { } else {
moveToNextWord(true); moveToNextWord(true, m_submode==DeleteSubMode);
m_movetype = MoveExclusive; m_movetype = MoveExclusive;
} }
finishMovement("%1W", count()); finishMovement("%1W", count());
@@ -2743,7 +2743,7 @@ void FakeVimHandler::Private::handleFfTt(int key)
setTargetColumn(); setTargetColumn();
} }
void FakeVimHandler::Private::moveToNextWord(bool simple) void FakeVimHandler::Private::moveToNextWord(bool simple, bool deleteWord)
{ {
int repeat = count(); int repeat = count();
int n = lastPositionInDocument(); int n = lastPositionInDocument();
@@ -2757,8 +2757,13 @@ void FakeVimHandler::Private::moveToNextWord(bool simple)
break; break;
lastClass = thisClass; lastClass = thisClass;
moveRight(); moveRight();
if (m_tc.block().length() == 1) // empty line if (deleteWord) {
--repeat; if (m_tc.atBlockEnd())
--repeat;
} else {
if (m_tc.block().length() == 1) // empty line
--repeat;
}
if (repeat == 0) if (repeat == 0)
break; break;
if (m_tc.position() == n) if (m_tc.position() == n)

View File

@@ -439,8 +439,7 @@ void tst_FakeVim::command_dw()
check("dw", "@<QtCore>\n" + lmid(2)); check("dw", "@<QtCore>\n" + lmid(2));
check("dw", "@QtCore>\n" + lmid(2)); check("dw", "@QtCore>\n" + lmid(2));
check("dw", "@>\n" + lmid(2)); check("dw", "@>\n" + lmid(2));
qWarning("FIXME"); check("dw", "@\n" + lmid(2)); // Real vim has this intermediate step, too
//check("dw", "@\n" + lmid(2)); // FIXME: Real vim has this intermediate step
check("dw", "@#include <QtGui>\n" + lmid(3)); check("dw", "@#include <QtGui>\n" + lmid(3));
check("dw", "@include <QtGui>\n" + lmid(3)); check("dw", "@include <QtGui>\n" + lmid(3));
check("dw", "@<QtGui>\n" + lmid(3)); check("dw", "@<QtGui>\n" + lmid(3));