diff options
| author | hluk <hluk@email.cz> | 2014-02-19 19:18:14 +0100 |
|---|---|---|
| committer | hjk <hjk121@nokiamail.com> | 2014-02-21 13:31:12 +0100 |
| commit | d8a56f9dc1887b9eff2fbe8bd86a784860df456f (patch) | |
| tree | a9b39a0e85bdc216c9faa615bdeeee1a74336f28 | |
| parent | b633fc186a8d133dff05748636d3f6708ff58134 (diff) | |
| download | qt-creator-d8a56f9dc1887b9eff2fbe8bd86a784860df456f.tar.gz | |
FakeVim: Save and restore cursor if handling custom Ex command
Change-Id: I38ee04fd76f92b0e0e5755e6a9f8828bd347c245
Reviewed-by: hjk <hjk121@nokiamail.com>
| -rw-r--r-- | src/plugins/fakevim/fakevimhandler.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index e61b66e572..7f1fc081ad 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -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); |
