Commit 2fb8590f authored by hluk's avatar hluk Committed by hjk
Browse files

FakeVim: Fix behavior of 'dw' command



Task-number: QTCREATORBUG-9289
Change-Id: I7ac1c925a13df49d60db410dce2d90b02cac7cfd
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 80cef809
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment