Skip to content
Snippets Groups Projects
Commit 0e93bf3b authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Activate the global completion when the the character at the left of the text...

Activate the global completion when the the character at the left of the text cursor is a delimiter.
parent 7ddfd865
No related branches found
No related tags found
No related merge requests found
...@@ -762,6 +762,24 @@ bool QmlCodeCompletion::isImported(Document::Ptr doc, const QString &currentFile ...@@ -762,6 +762,24 @@ bool QmlCodeCompletion::isImported(Document::Ptr doc, const QString &currentFile
return false; 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) int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
{ {
m_editor = editor; m_editor = editor;
...@@ -913,8 +931,8 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) ...@@ -913,8 +931,8 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (m_startPosition > 0) if (m_startPosition > 0)
completionOperator = editor->characterAt(m_startPosition - 1); completionOperator = editor->characterAt(m_startPosition - 1);
if (completionOperator.isSpace() || completionOperator.isNull() || (completionOperator == QLatin1Char('(') && if (completionOperator.isSpace() || completionOperator.isNull() || isDelimiter(completionOperator) ||
m_startPosition != editor->position())) { (completionOperator == QLatin1Char('(') && m_startPosition != editor->position())) {
// It's a global completion. // It's a global completion.
// Process the visible user defined components. // Process the visible user defined components.
QHashIterator<QString, Document::Ptr> componentIt(userComponents); QHashIterator<QString, Document::Ptr> componentIt(userComponents);
......
...@@ -75,6 +75,8 @@ private: ...@@ -75,6 +75,8 @@ private:
void updateSnippets(); void updateSnippets();
bool isImported(QmlJS::Document::Ptr doc, const QString &currentFilePath) const; bool isImported(QmlJS::Document::Ptr doc, const QString &currentFilePath) const;
bool isDelimiter(const QChar &ch) const;
QmlModelManagerInterface *m_modelManager; QmlModelManagerInterface *m_modelManager;
TextEditor::ITextEditable *m_editor; TextEditor::ITextEditable *m_editor;
int m_startPosition; int m_startPosition;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment