FakeVim: Disable visual navigation for text cursor

Change-Id: I04a05ae034dbe5e891df5e39275ce0430eabb649
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Lukas Holecek
2015-05-16 09:21:36 +02:00
committed by hjk
parent 04a03106ce
commit a439335500

View File

@@ -1913,6 +1913,8 @@ public:
// changes externally (e.g. by code completion).
void pullCursor();
QTextCursor editorCursor() const;
// Values to save when starting FakeVim processing.
int m_firstVisibleLine;
QTextCursor m_cursor;
@@ -2404,7 +2406,7 @@ void FakeVimHandler::Private::fixExternalCursor(bool focus)
void FakeVimHandler::Private::fixExternalCursorPosition(bool focus)
{
QTextCursor tc = EDITOR(textCursor());
QTextCursor tc = editorCursor();
if (tc.anchor() < tc.position()) {
tc.movePosition(focus ? Left : Right, KeepAnchor);
EDITOR(setTextCursor(tc));
@@ -3220,7 +3222,7 @@ void FakeVimHandler::Private::pullCursor()
if (visualBlockMode)
q->requestBlockSelection(&m_cursor);
else if (editor())
m_cursor = EDITOR(textCursor());
m_cursor = editorCursor();
// Cursor should be always valid.
if (m_cursor.isNull())
@@ -3249,6 +3251,13 @@ void FakeVimHandler::Private::pullCursor()
setTargetColumn();
}
QTextCursor FakeVimHandler::Private::editorCursor() const
{
QTextCursor tc = EDITOR(textCursor());
tc.setVisualNavigation(false);
return tc;
}
bool FakeVimHandler::Private::moveToNextParagraph(int count)
{
const bool forward = count > 0;
@@ -7334,7 +7343,7 @@ bool FakeVimHandler::Private::passEventToEditor(QEvent &event, QTextCursor &tc)
return false;
if (accepted)
tc = EDITOR(textCursor());
tc = editorCursor();
return accepted;
}
@@ -7658,7 +7667,7 @@ void FakeVimHandler::Private::onCursorPositionChanged()
// Selecting text with mouse disables the thick cursor so it's more obvious
// that extra character under cursor is not selected when moving text around or
// making operations on text outside FakeVim mode.
setThinCursor(g.mode == InsertMode || EDITOR(textCursor()).hasSelection());
setThinCursor(g.mode == InsertMode || editorCursor().hasSelection());
}
}