diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-06-05 14:19:43 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-06-05 14:19:43 +0200 |
commit | a503f8bee012839d03bbba106da2eb3312bacd9d (patch) | |
tree | 36c6c00debfd740f43a1bf0cba1101efe00bd59f /src/plugins/fakevim | |
parent | c770e7074ff59e394259193f5d21fee15a9d327a (diff) | |
parent | ea3ac259d0c38a793768345cfa9197ea77d56842 (diff) | |
download | qt-creator-a503f8bee012839d03bbba106da2eb3312bacd9d.tar.gz |
Merge remote-tracking branch 'origin/2.8'
Conflicts:
qtcreator.pri
qtcreator.qbs
src/libs/extensionsystem/pluginmanager.cpp
src/plugins/coreplugin/documentmanager.cpp
src/plugins/fakevim/fakevimhandler.cpp
Change-Id: Ibc2adc40bad6f10df94c50d66e78dc3f4bcb84c0
Diffstat (limited to 'src/plugins/fakevim')
-rw-r--r-- | src/plugins/fakevim/fakevim_test.cpp | 23 | ||||
-rw-r--r-- | src/plugins/fakevim/fakevimhandler.cpp | 47 | ||||
-rw-r--r-- | src/plugins/fakevim/fakevimplugin.cpp | 2 |
3 files changed, 62 insertions, 10 deletions
diff --git a/src/plugins/fakevim/fakevim_test.cpp b/src/plugins/fakevim/fakevim_test.cpp index ae2a7a31c3..e946ae20da 100644 --- a/src/plugins/fakevim/fakevim_test.cpp +++ b/src/plugins/fakevim/fakevim_test.cpp @@ -786,6 +786,29 @@ 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"); + + data.setText("abc" N "def"); + KEYS("2lvx", "a" X "b" N "def"); + KEYS("vlx", "a" X "def"); + + data.setText("abc" N "def"); + KEYS("2lvox", "a" X "b" N "def"); + KEYS("vlox", "a" X "def"); } void FakeVimPlugin::test_vim_delete_inner_word() diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 6de785baca..695578a9f1 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -1502,11 +1502,11 @@ public: int count() const { return mvCount() * opCount(); } QTextBlock block() const { return m_cursor.block(); } int leftDist() const { return position() - block().position(); } - int rightDist() const { return block().length() - leftDist() - 1; } + int rightDist() const { return block().length() - leftDist() - (isVisualCharMode() ? 0 : 1); } 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; @@ -1605,7 +1605,14 @@ public: } void moveRight(int n = 1) { //dump("RIGHT 1"); - m_cursor.movePosition(Right, KeepAnchor, n); + if (isVisualCharMode()) { + const QTextBlock currentBlock = block(); + const int max = currentBlock.position() + currentBlock.length() - 1; + const int pos = position() + n; + setPosition(qMin(pos, max)); + } else { + m_cursor.movePosition(Right, KeepAnchor, n); + } if (atEndOfLine()) emit q->fold(1, false); //dump("RIGHT 2"); @@ -2060,7 +2067,8 @@ void FakeVimHandler::Private::leaveFakeVim() // The command might have destroyed the editor. if (m_textedit || m_plaintextedit) { // We fake vi-style end-of-line behaviour - m_fakeEnd = atEndOfLine() && g.mode == CommandMode && !isVisualBlockMode(); + m_fakeEnd = atEndOfLine() && g.m_mode == CommandMode && !isVisualBlockMode() + && !isVisualCharMode(); //QTC_ASSERT(g.mode == InsertMode || g.mode == ReplaceMode // || !atBlockEnd() || block().length() <= 1, @@ -2247,7 +2255,7 @@ void FakeVimHandler::Private::exportSelection() if (visualBlockInverted) setAnchorAndPosition(anc + 1, pos); else - setAnchorAndPosition(anc, pos + 1); + setAnchorAndPosition(anc, pos); if (g.visualMode == VisualBlockMode) { commitCursor(); @@ -2824,6 +2832,23 @@ void FakeVimHandler::Private::fixSelection() if (g.rangemode == RangeBlockMode) return; + if (g.movetype == MoveInclusive) { + // If position or anchor is after end of non-empty line, include line break in selection. + if (document()->characterAt(position()) == ParagraphSeparator) { + if (!atEmptyLine()) { + setPosition(position() + 1); + return; + } + } else if (document()->characterAt(anchor()) == ParagraphSeparator) { + QTextCursor tc = m_cursor; + tc.setPosition(anchor()); + if (!atEmptyLine(tc)) { + setAnchorAndPosition(anchor() + 1, position()); + return; + } + } + } + if (g.movetype == MoveExclusive) { if (anchor() < position() && atBlockStart()) { // Exlusive motion ending at the beginning of line @@ -3529,6 +3554,11 @@ bool FakeVimHandler::Private::handleMovement(const Input &input) g.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())); + } g.movetype = MoveExclusive; } setTargetColumn(); @@ -7270,10 +7300,9 @@ void FakeVimHandler::Private::redo() void FakeVimHandler::Private::updateCursorShape() { bool thinCursor = g.mode == ExMode - || g.subsubmode == SearchSubSubMode + || g.ubsubmode == SearchSubSubMode || g.mode == InsertMode - || isVisualMode() - || m_cursor.hasSelection(); + || (isVisualMode() && !isVisualCharMode()); EDITOR(setOverwriteMode(!thinCursor)); } @@ -7349,7 +7378,7 @@ void FakeVimHandler::Private::initVisualInsertMode(QChar command) void FakeVimHandler::Private::enterCommandMode(Mode returnToMode) { - if (atEndOfLine()) + if (isNoVisualMode() && atEndOfLine()) moveLeft(); g.mode = CommandMode; clearCommandMode(); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 235696eda6..3d9c30356a 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1324,7 +1324,7 @@ void FakeVimPluginPrivate::windowCommand(const QString &map, int count) else if (key == _("S") || key == _("<C-S>")) triggerAction(Core::Constants::SPLIT); else if (key == _("W") || key == _("<C-W>")) - triggerAction(Core::Constants::GOTO_OTHER_SPLIT); + triggerAction(Core::Constants::GOTO_NEXT_SPLIT); else if (key.contains(_("RIGHT")) || key == _("L") || key == _("<S-L>")) moveSomewhere(&moveRightWeight, key == _("<S-L>") ? -1 : count); else if (key.contains(_("LEFT")) || key == _("H") || key == _("<S-H>")) |