Commit 764f902c authored by hjk's avatar hjk Committed by hjk
Browse files

fakevim: v in visual mode actually leave visual mode

Task-number: QTCREATORBUG-5603
Change-Id: I239837b1d8ad30fdc157a6eaec05a026c294a75c
Reviewed-on: http://codereview.qt.nokia.com/2525

Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 191ba368
...@@ -968,8 +968,8 @@ public: ...@@ -968,8 +968,8 @@ public:
Input m_semicolonType; // 'f', 'F', 't', 'T' Input m_semicolonType; // 'f', 'F', 't', 'T'
QString m_semicolonKey; QString m_semicolonKey;
// visual line mode // visual modes
void enterVisualMode(VisualMode visualMode); void toggleVisualMode(VisualMode visualMode);
void leaveVisualMode(); void leaveVisualMode();
VisualMode m_visualMode; VisualMode m_visualMode;
VisualMode m_oldVisualMode; VisualMode m_oldVisualMode;
...@@ -2575,11 +2575,11 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input) ...@@ -2575,11 +2575,11 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
scrollToLine(cursorLine() - sline); scrollToLine(cursorLine() - sline);
finishMovement(); finishMovement();
} else if (input.is('v')) { } else if (input.is('v')) {
enterVisualMode(VisualCharMode); toggleVisualMode(VisualCharMode);
} else if (input.is('V')) { } else if (input.is('V')) {
enterVisualMode(VisualLineMode); toggleVisualMode(VisualLineMode);
} else if (input.isControl('v')) { } else if (input.isControl('v')) {
enterVisualMode(VisualBlockMode); toggleVisualMode(VisualBlockMode);
} else if (input.is('w')) { // tested } else if (input.is('w')) { // tested
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the // 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 // cursor is on a non-blank - except if the cursor is on the last
...@@ -4651,17 +4651,21 @@ int FakeVimHandler::Private::lineForPosition(int pos) const ...@@ -4651,17 +4651,21 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
return tc.block().blockNumber() + 1; return tc.block().blockNumber() + 1;
} }
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode) void FakeVimHandler::Private::toggleVisualMode(VisualMode visualMode)
{ {
m_positionPastEnd = false; if (isVisualMode()) {
m_anchorPastEnd = false; leaveVisualMode();
m_visualMode = visualMode; } else {
const int pos = position(); m_positionPastEnd = false;
//setMark('<', pos); m_anchorPastEnd = false;
//setMark('>', pos + 1); m_visualMode = visualMode;
setAnchorAndPosition(pos, pos); const int pos = position();
updateMiniBuffer(); //setMark('<', pos);
updateSelection(); //setMark('>', pos + 1);
setAnchorAndPosition(pos, pos);
updateMiniBuffer();
updateSelection();
}
} }
void FakeVimHandler::Private::leaveVisualMode() void FakeVimHandler::Private::leaveVisualMode()
......
Supports Markdown
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