diff --git a/src/plugins/qmljseditor/qmlcodecompletion.cpp b/src/plugins/qmljseditor/qmlcodecompletion.cpp index 1c945682574d698721969882b8bf893ce9eda1c3..56a62c98c950436bac8c34c13f75638d89d4d57f 100644 --- a/src/plugins/qmljseditor/qmlcodecompletion.cpp +++ b/src/plugins/qmljseditor/qmlcodecompletion.cpp @@ -762,6 +762,24 @@ bool QmlCodeCompletion::isImported(Document::Ptr doc, const QString ¤tFile return false; } +bool QmlCodeCompletion::isDelimiter(const QChar &ch) const +{ + switch (ch.unicode()) { + case '{': + case '}': + case '[': + case ']': + case '?': + case ':': + case ';': + case ',': + return true; + + default: + return false; + } +} + int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) { m_editor = editor; @@ -913,8 +931,8 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) if (m_startPosition > 0) completionOperator = editor->characterAt(m_startPosition - 1); - if (completionOperator.isSpace() || completionOperator.isNull() || (completionOperator == QLatin1Char('(') && - m_startPosition != editor->position())) { + if (completionOperator.isSpace() || completionOperator.isNull() || isDelimiter(completionOperator) || + (completionOperator == QLatin1Char('(') && m_startPosition != editor->position())) { // It's a global completion. // Process the visible user defined components. QHashIterator<QString, Document::Ptr> componentIt(userComponents); diff --git a/src/plugins/qmljseditor/qmlcodecompletion.h b/src/plugins/qmljseditor/qmlcodecompletion.h index b56e246b0308d32e8fb8867fc064ebbba87cad91..b329f8131b049ee7d59c8ddddff421942802381f 100644 --- a/src/plugins/qmljseditor/qmlcodecompletion.h +++ b/src/plugins/qmljseditor/qmlcodecompletion.h @@ -75,6 +75,8 @@ private: void updateSnippets(); bool isImported(QmlJS::Document::Ptr doc, const QString ¤tFilePath) const; + bool isDelimiter(const QChar &ch) const; + QmlModelManagerInterface *m_modelManager; TextEditor::ITextEditable *m_editor; int m_startPosition;