Commit d7747fe8 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Trigger another completion if a completion ends with a dot.

parent 3b8b6e89
...@@ -479,7 +479,8 @@ CodeCompletion::CodeCompletion(ModelManagerInterface *modelManager, QObject *par ...@@ -479,7 +479,8 @@ CodeCompletion::CodeCompletion(ModelManagerInterface *modelManager, QObject *par
: TextEditor::ICompletionCollector(parent), : TextEditor::ICompletionCollector(parent),
m_modelManager(modelManager), m_modelManager(modelManager),
m_editor(0), m_editor(0),
m_startPosition(0) m_startPosition(0),
m_restartCompletion(false)
{ {
Q_ASSERT(modelManager); Q_ASSERT(modelManager);
} }
...@@ -494,7 +495,7 @@ int CodeCompletion::startPosition() const ...@@ -494,7 +495,7 @@ int CodeCompletion::startPosition() const
{ return m_startPosition; } { return m_startPosition; }
bool CodeCompletion::shouldRestartCompletion() bool CodeCompletion::shouldRestartCompletion()
{ return false; } { return m_restartCompletion; }
bool CodeCompletion::supportsEditor(TextEditor::ITextEditable *editor) bool CodeCompletion::supportsEditor(TextEditor::ITextEditable *editor)
{ {
...@@ -649,6 +650,8 @@ void CodeCompletion::addCompletionsPropertyLhs( ...@@ -649,6 +650,8 @@ void CodeCompletion::addCompletionsPropertyLhs(
int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
{ {
m_restartCompletion = false;
m_editor = editor; m_editor = editor;
QmlJSTextEditor *edit = qobject_cast<QmlJSTextEditor *>(m_editor->widget()); QmlJSTextEditor *edit = qobject_cast<QmlJSTextEditor *>(m_editor->widget());
...@@ -882,6 +885,9 @@ void CodeCompletion::complete(const TextEditor::CompletionItem &item) ...@@ -882,6 +885,9 @@ void CodeCompletion::complete(const TextEditor::CompletionItem &item)
const int length = m_editor->position() - m_startPosition; const int length = m_editor->position() - m_startPosition;
m_editor->setCurPos(m_startPosition); m_editor->setCurPos(m_startPosition);
m_editor->replace(length, toInsert); m_editor->replace(length, toInsert);
if (toInsert.endsWith(QLatin1Char('.')))
m_restartCompletion = true;
} }
bool CodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems) bool CodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems)
......
...@@ -96,6 +96,7 @@ private: ...@@ -96,6 +96,7 @@ private:
QList<TextEditor::CompletionItem> m_snippets; QList<TextEditor::CompletionItem> m_snippets;
QDateTime m_snippetFileLastModified; QDateTime m_snippetFileLastModified;
QPointer<FunctionArgumentWidget> m_functionArgumentWidget; QPointer<FunctionArgumentWidget> m_functionArgumentWidget;
bool m_restartCompletion;
}; };
......
Supports Markdown
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