summaryrefslogtreecommitdiff
path: root/src/plugins/fakevim
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2011-08-02 17:59:05 +0200
committerEike Ziller <eike.ziller@nokia.com>2011-08-04 09:15:33 +0200
commit1a0056eea9126246d2cd782de2305e167cf2c946 (patch)
treebdc51a4418fe2066a96a76d4453df33e2f49b037 /src/plugins/fakevim
parent86e6cc6728e9cbb918486d14c7079617b5af1f15 (diff)
downloadqt-creator-1a0056eea9126246d2cd782de2305e167cf2c946.tar.gz
fakevim: v in visual mode actually leave visual mode
Task-number: QTCREATORBUG-5603 Change-Id: I239837b1d8ad30fdc157a6eaec05a026c294a750 (cherry picked from commit 764f902cf39da75260a1771d6d55a2f41be8dcca) Reviewed-on: http://codereview.qt.nokia.com/2578 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Diffstat (limited to 'src/plugins/fakevim')
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 6372beefb9..f441747696 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -906,8 +906,8 @@ public:
Input m_semicolonType; // 'f', 'F', 't', 'T'
QString m_semicolonKey;
- // visual line mode
- void enterVisualMode(VisualMode visualMode);
+ // visual modes
+ void toggleVisualMode(VisualMode visualMode);
void leaveVisualMode();
VisualMode m_visualMode;
VisualMode m_oldVisualMode;
@@ -2520,11 +2520,11 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
scrollToLine(cursorLine() - sline);
finishMovement();
} else if (input.is('v')) {
- enterVisualMode(VisualCharMode);
+ toggleVisualMode(VisualCharMode);
} else if (input.is('V')) {
- enterVisualMode(VisualLineMode);
+ toggleVisualMode(VisualLineMode);
} else if (input.isControl('v')) {
- enterVisualMode(VisualBlockMode);
+ toggleVisualMode(VisualBlockMode);
} else if (input.is('w')) { // tested
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the
// cursor is on a non-blank - except if the cursor is on the last
@@ -4614,17 +4614,21 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
return tc.block().blockNumber() + 1;
}
-void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
+void FakeVimHandler::Private::toggleVisualMode(VisualMode visualMode)
{
- m_positionPastEnd = false;
- m_anchorPastEnd = false;
- m_visualMode = visualMode;
- const int pos = position();
- //setMark('<', pos);
- //setMark('>', pos + 1);
- setAnchorAndPosition(pos, pos);
- updateMiniBuffer();
- updateSelection();
+ if (isVisualMode()) {
+ leaveVisualMode();
+ } else {
+ m_positionPastEnd = false;
+ m_anchorPastEnd = false;
+ m_visualMode = visualMode;
+ const int pos = position();
+ //setMark('<', pos);
+ //setMark('>', pos + 1);
+ setAnchorAndPosition(pos, pos);
+ updateMiniBuffer();
+ updateSelection();
+ }
}
void FakeVimHandler::Private::leaveVisualMode()