Activate the global completion when the the character at the left of the text cursor is a delimiter.

This commit is contained in:
Roberto Raggi
2010-01-26 12:36:04 +01:00
parent 7ddfd8659a
commit 0e93bf3b96
2 changed files with 22 additions and 2 deletions

View File

@@ -762,6 +762,24 @@ bool QmlCodeCompletion::isImported(Document::Ptr doc, const QString &currentFile
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);