forked from qt-creator/qt-creator
Activate the global completion when the the character at the left of the text cursor is a delimiter.
This commit is contained in:
@@ -762,6 +762,24 @@ bool QmlCodeCompletion::isImported(Document::Ptr doc, const QString ¤tFile
|
|||||||
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)
|
|||||||
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:
|
|||||||
void updateSnippets();
|
void updateSnippets();
|
||||||
bool isImported(QmlJS::Document::Ptr doc, const QString ¤tFilePath) const;
|
bool isImported(QmlJS::Document::Ptr doc, const QString ¤tFilePath) 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user