FakeVim: Fix Vk command

Fixes visual representation (selection exported to editor widget) of
"Vk" command on empty line.

Change-Id: Iac5fabe53a65d7b94d0a1ed02aff3a7b3804a37b
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hluk
2013-08-05 18:02:50 +02:00
committed by hjk
parent 4f8c4a8840
commit 1b13122cd1

View File

@@ -2273,12 +2273,7 @@ void FakeVimHandler::Private::exportSelection()
++anc; ++anc;
else else
++pos; ++pos;
} else if (anc > pos) {
++anc;
}
setAnchorAndPosition(anc, pos); setAnchorAndPosition(anc, pos);
if (g.visualMode == VisualBlockMode) {
commitCursor(); commitCursor();
emit q->requestSetBlockSelection(false); emit q->requestSetBlockSelection(false);
emit q->requestSetBlockSelection(true); emit q->requestSetBlockSelection(true);
@@ -2290,18 +2285,21 @@ void FakeVimHandler::Private::exportSelection()
anc = firstPositionInLine(ancLine); anc = firstPositionInLine(ancLine);
} else { } else {
pos = firstPositionInLine(posLine); pos = firstPositionInLine(posLine);
anc = lastPositionInLine(ancLine); anc = lastPositionInLine(ancLine) + 1;
} }
// putting cursor on folded line will unfold the line, so move the cursor a bit // putting cursor on folded line will unfold the line, so move the cursor a bit
if (!document()->findBlock(pos).isVisible()) if (!document()->findBlock(pos).isVisible())
++pos; ++pos;
setAnchorAndPosition(anc, pos); setAnchorAndPosition(anc, pos);
} else if (g.visualMode == VisualCharMode) { } else if (g.visualMode == VisualCharMode) {
/* Nothing */ if (anc > pos)
++anc;
} else { } else {
QTC_CHECK(false); QTC_CHECK(false);
} }
setAnchorAndPosition(anc, pos);
setMark(QLatin1Char('<'), mark(QLatin1Char('<')).position); setMark(QLatin1Char('<'), mark(QLatin1Char('<')).position);
setMark(QLatin1Char('>'), mark(QLatin1Char('>')).position); setMark(QLatin1Char('>'), mark(QLatin1Char('>')).position);
} else { } else {