forked from qt-creator/qt-creator
FakeVim: Fix behavior of 'dw' command
Task-number: QTCREATORBUG-9289 Change-Id: I7ac1c925a13df49d60db410dce2d90b02cac7cfd Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -786,6 +786,21 @@ void FakeVimPlugin::test_vim_delete()
|
||||
KEYS("\"xd$", X "" N "def");
|
||||
KEYS("\"xp", "ab" X "c" N "def");
|
||||
KEYS("2\"xp", "abcabcab" X "c" N "def");
|
||||
|
||||
/* QTCREATORBUG-9289 */
|
||||
data.setText("abc" N "def");
|
||||
KEYS("$" "dw", "a" X "b" N "def");
|
||||
KEYS("dw", X "a" N "def");
|
||||
KEYS("dw", X "" N "def");
|
||||
KEYS("dw", X "def");
|
||||
|
||||
data.setText("abc" N "def ghi");
|
||||
KEYS("2dw", X "ghi");
|
||||
|
||||
data.setText("abc" N X "" N "def");
|
||||
KEYS("dw", "abc" N X "def");
|
||||
KEYS("k$" "dw", "a" X "b" N "def");
|
||||
KEYS("j$h" "dw", "ab" N X "d");
|
||||
}
|
||||
|
||||
void FakeVimPlugin::test_vim_delete_inner_word()
|
||||
|
@@ -1505,7 +1505,7 @@ public:
|
||||
bool atBlockStart() const { return m_cursor.atBlockStart(); }
|
||||
bool atBlockEnd() const { return m_cursor.atBlockEnd(); }
|
||||
bool atEndOfLine() const { return atBlockEnd() && block().length() > 1; }
|
||||
bool atDocumentEnd() const { return position() >= lastPositionInDocument(); }
|
||||
bool atDocumentEnd() const { return position() >= lastPositionInDocument(true); }
|
||||
bool atDocumentStart() const { return m_cursor.atStart(); }
|
||||
|
||||
bool atEmptyLine(const QTextCursor &tc = QTextCursor()) const;
|
||||
@@ -3507,6 +3507,11 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
|
||||
m_movetype = MoveInclusive;
|
||||
} else {
|
||||
moveToNextWordStart(count, simple, true);
|
||||
// Command 'dw' deletes to the next word on the same line or to end of line.
|
||||
if (m_submode == DeleteSubMode && count == 1) {
|
||||
const QTextBlock currentBlock = document()->findBlock(anchor());
|
||||
setPosition(qMin(position(), currentBlock.position() + currentBlock.length()));
|
||||
}
|
||||
m_movetype = MoveExclusive;
|
||||
}
|
||||
setTargetColumn();
|
||||
|
Reference in New Issue
Block a user