From 5af95f01f04b355388742165b6577be50a4752d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Aum=C3=BCller?= <aumuell@reserv.at>
Date: Fri, 19 Feb 2010 13:01:39 +0100
Subject: [PATCH] fakevim: only overwrite m_tc with EDITOR's cursor if
 necessary

only ex commands that are handled externally might modify the cursor position w/o updating m_tc

Merge-request: 113
Reviewed-by: hjk <qtc-committer@nokia.com>
---
 src/plugins/fakevim/fakevimhandler.cpp | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 694b7a65f77..a734b46a46c 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -2132,15 +2132,10 @@ EventResult FakeVimHandler::Private::handleMiniBufferModes(int key, int unmodifi
         if (!m_commandBuffer.isEmpty()) {
             m_commandHistory.takeLast();
             m_commandHistory.append(m_commandBuffer);
-            // FIXME: This was inserted to prevent crashes when the
-            // editor 'vanishes' but broke things like :<line>.
-            // How can the crash be reproduced?
-            // when EDITOR(setTextCursor(m_tc));
             handleExCommand(m_commandBuffer);
-            //if (m_textedit || m_plaintextedit) {
-            //    m_tc = EDITOR(textCursor());
-            leaveVisualMode();
-            //}
+            if (m_textedit || m_plaintextedit) {
+                leaveVisualMode();
+            }
         }
     } else if (unmodified == Key_Return && isSearchMode()) {
         if (!m_commandBuffer.isEmpty()) {
@@ -2559,7 +2554,10 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
 
 void FakeVimHandler::Private::passUnknownExCommand(const QString &cmd)
 {
+    EDITOR(setTextCursor(m_tc));
     emit q->handleExCommandRequested(cmd);
+    if (m_plaintextedit || m_textedit)
+        m_tc = EDITOR(textCursor());
 }
 
 void FakeVimHandler::Private::passUnknownSetCommand(const QString &arg)
-- 
GitLab