From 0807ca53c984fa1bfbf929618ce9315d2701124b Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Wed, 25 Mar 2009 14:52:13 +0100
Subject: [PATCH] fakevim: fine-tune autocompletion

---
 src/plugins/fakevim/fakevimhandler.cpp  | 10 +++++++---
 src/plugins/fakevim/fakevimplugin.cpp   |  5 ++++-
 tests/manual/gdbdebugger/simple/app.cpp |  1 +
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index b42c4d011e1..743abdb1f2a 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -358,6 +358,7 @@ public:
 
     // extra data for '.'
     QString m_dotCommand;
+    bool m_inReplay; // true if we are executing a '.'
 
     // extra data for ';'
     QString m_semicolonCount;
@@ -424,8 +425,9 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
     m_anchor = 0;
     m_savedYankPosition = 0;
     m_cursorWidth = EDITOR(cursorWidth());
+    m_inReplay = false;
 
-#if 1
+#if 0
     // Plain
     m_config[ConfigStartOfLine] = ConfigOn;
     m_config[ConfigHlSearch]    = ConfigOn;
@@ -1012,9 +1014,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
         qDebug() << "REPEATING" << m_dotCommand;
         QString savedCommand = m_dotCommand;
         m_dotCommand.clear();
+        m_inReplay = true;
         for (int i = count(); --i >= 0; )
             foreach (QChar c, savedCommand)
                 handleKey(c.unicode(), c.unicode(), QString(c));
+        m_inReplay = false;
         enterCommandMode();
         m_dotCommand = savedCommand;
     } else if (key == '<' && m_visualMode == NoVisualMode) {
@@ -1512,8 +1516,8 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int,
             if (leftText.simplified().isEmpty())
                 indentRegion(text.at(0));
         }
-        
-        if (text.at(0) == '.' || text.at(0) == '>')
+       
+        if (!m_inReplay) 
             emit q->completionRequested();
     } else {
         return EventUnhandled;
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 8ece7de8724..65e907cdd8f 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -47,6 +47,7 @@
 
 #include <texteditor/basetexteditor.h>
 #include <texteditor/basetextmark.h>
+#include <texteditor/completionsupport.h>
 #include <texteditor/itexteditor.h>
 #include <texteditor/texteditorconstants.h>
 #include <texteditor/interactionsettings.h>
@@ -244,7 +245,9 @@ void FakeVimPluginPrivate::triggerCompletions()
     if (!handler)
         return;
     if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget()))
-        bt->triggerCompletions();
+        TextEditor::Internal::CompletionSupport::instance()->
+            autoComplete(bt->editableInterface(), false);
+   //     bt->triggerCompletions();
 }
 
 void FakeVimPluginPrivate::writeFile(bool *handled,
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 4115a49a508..6ab3cd96901 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -710,6 +710,7 @@ void testQString()
     str += " World ";
     str += " World ";
     str += " World ";
+    str.append(s);
 }
 
 void testQString3()
-- 
GitLab