fakevim: Display visual block selection correctly

Change-Id: Id33544265c0266e0a43a811b5a00aa94dfcc4f37
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Lukas Holecek
2012-12-04 21:36:38 +01:00
committed by hjk
parent f50dc8e06f
commit c50c4269ad

View File

@@ -2056,10 +2056,18 @@ void FakeVimHandler::Private::exportSelection()
m_oldInternalAnchor = anc;
if (isVisualMode()) {
if (pos >= anc)
setAnchorAndPosition(anc, pos + 1);
else
bool visualBlockInverted;
if (m_visualMode == VisualBlockMode) {
const int col1 = anc - document()->findBlock(anc).position();
const int col2 = pos - document()->findBlock(pos).position();
visualBlockInverted = col1 > col2;
} else {
visualBlockInverted = anc > pos;
}
if (visualBlockInverted)
setAnchorAndPosition(anc + 1, pos);
else
setAnchorAndPosition(anc, pos + 1);
if (m_visualMode == VisualBlockMode) {
emit q->requestSetBlockSelection(false);