Commit d8a56f9d authored by hluk's avatar hluk Committed by hjk

FakeVim: Save and restore cursor if handling custom Ex command

Change-Id: I38ee04fd76f92b0e0e5755e6a9f8828bd347c245
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent b633fc18
......@@ -1780,6 +1780,11 @@ public:
if (editor())
EDITOR(setTextCursor(m_cursor));
}
// Restore cursor from editor widget.
void pullCursor() {
if (editor())
m_cursor = EDITOR(textCursor());
}
// Values to save when starting FakeVim processing.
int m_firstVisibleLine;
......@@ -2235,7 +2240,7 @@ void FakeVimHandler::Private::enterFakeVim()
{
QTC_ASSERT(!m_inFakeVim, qDebug() << "enterFakeVim() shouldn't be called recursively!"; return);
m_cursor = EDITOR(textCursor());
pullCursor();
if (m_cursor.isNull())
m_cursor = QTextCursor(document());
......@@ -6093,8 +6098,15 @@ bool FakeVimHandler::Private::handleExCommandHelper(ExCommand &cmd)
bool FakeVimHandler::Private::handleExPluginCommand(const ExCommand &cmd)
{
bool handled = false;
int pos = m_cursor.position();
commitCursor();
emit q->handleExCommandRequested(&handled, cmd);
//qDebug() << "HANDLER REQUEST: " << cmd.cmd << handled;
if (handled) {
pullCursor();
if (m_cursor.position() != pos)
recordJump(pos);
}
return handled;
}
......@@ -7276,7 +7288,7 @@ bool FakeVimHandler::Private::passEventToEditor(QEvent &event)
updateCursorShape();
if (accepted)
m_cursor = EDITOR(textCursor());
pullCursor();
return accepted;
}
......@@ -7659,7 +7671,7 @@ void FakeVimHandler::Private::undoRedo(bool undo)
state.revision = previousRevision;
} else {
updateFirstVisibleLine();
m_cursor = EDITOR(textCursor());
pullCursor();
}
stack2.push(state);
......
Markdown is supported
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