Commit 0807ca53 authored by hjk's avatar hjk
Browse files

fakevim: fine-tune autocompletion

parent 573b33d7
...@@ -358,6 +358,7 @@ public: ...@@ -358,6 +358,7 @@ public:
// extra data for '.' // extra data for '.'
QString m_dotCommand; QString m_dotCommand;
bool m_inReplay; // true if we are executing a '.'
// extra data for ';' // extra data for ';'
QString m_semicolonCount; QString m_semicolonCount;
...@@ -424,8 +425,9 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget) ...@@ -424,8 +425,9 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
m_anchor = 0; m_anchor = 0;
m_savedYankPosition = 0; m_savedYankPosition = 0;
m_cursorWidth = EDITOR(cursorWidth()); m_cursorWidth = EDITOR(cursorWidth());
m_inReplay = false;
#if 1 #if 0
// Plain // Plain
m_config[ConfigStartOfLine] = ConfigOn; m_config[ConfigStartOfLine] = ConfigOn;
m_config[ConfigHlSearch] = ConfigOn; m_config[ConfigHlSearch] = ConfigOn;
...@@ -1012,9 +1014,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1012,9 +1014,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
qDebug() << "REPEATING" << m_dotCommand; qDebug() << "REPEATING" << m_dotCommand;
QString savedCommand = m_dotCommand; QString savedCommand = m_dotCommand;
m_dotCommand.clear(); m_dotCommand.clear();
m_inReplay = true;
for (int i = count(); --i >= 0; ) for (int i = count(); --i >= 0; )
foreach (QChar c, savedCommand) foreach (QChar c, savedCommand)
handleKey(c.unicode(), c.unicode(), QString(c)); handleKey(c.unicode(), c.unicode(), QString(c));
m_inReplay = false;
enterCommandMode(); enterCommandMode();
m_dotCommand = savedCommand; m_dotCommand = savedCommand;
} else if (key == '<' && m_visualMode == NoVisualMode) { } else if (key == '<' && m_visualMode == NoVisualMode) {
...@@ -1512,8 +1516,8 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int, ...@@ -1512,8 +1516,8 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int,
if (leftText.simplified().isEmpty()) if (leftText.simplified().isEmpty())
indentRegion(text.at(0)); indentRegion(text.at(0));
} }
if (text.at(0) == '.' || text.at(0) == '>') if (!m_inReplay)
emit q->completionRequested(); emit q->completionRequested();
} else { } else {
return EventUnhandled; return EventUnhandled;
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <texteditor/basetextmark.h> #include <texteditor/basetextmark.h>
#include <texteditor/completionsupport.h>
#include <texteditor/itexteditor.h> #include <texteditor/itexteditor.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/interactionsettings.h> #include <texteditor/interactionsettings.h>
...@@ -244,7 +245,9 @@ void FakeVimPluginPrivate::triggerCompletions() ...@@ -244,7 +245,9 @@ void FakeVimPluginPrivate::triggerCompletions()
if (!handler) if (!handler)
return; return;
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget())) 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, void FakeVimPluginPrivate::writeFile(bool *handled,
......
...@@ -710,6 +710,7 @@ void testQString() ...@@ -710,6 +710,7 @@ void testQString()
str += " World "; str += " World ";
str += " World "; str += " World ";
str += " World "; str += " World ";
str.append(s);
} }
void testQString3() void testQString3()
......
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