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:
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;
......@@ -2575,11 +2575,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
......@@ -4651,8 +4651,11 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
return tc.block().blockNumber() + 1;
}
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
void FakeVimHandler::Private::toggleVisualMode(VisualMode visualMode)
{
if (isVisualMode()) {
leaveVisualMode();
} else {
m_positionPastEnd = false;
m_anchorPastEnd = false;
m_visualMode = visualMode;
......@@ -4662,6 +4665,7 @@ void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
setAnchorAndPosition(pos, pos);
updateMiniBuffer();
updateSelection();
}
}
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