Fix SIGNAL/SLOT completion with spaces after opening brace

Spaces after the opening brace would cause SIGNAL/SLOT completion to be
disabled along with function completion. Now function completion is
checked at a later stage.
This commit is contained in:
Thorbjørn Lindeijer
2009-01-26 15:51:14 +01:00
parent 9c897b4411
commit 8c59160792

View File

@@ -435,15 +435,15 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_startPosition = findStartOfName(editor); m_startPosition = findStartOfName(editor);
m_completionOperator = T_EOF_SYMBOL; m_completionOperator = T_EOF_SYMBOL;
int endOfExpression = m_startPosition; int endOfOperator = m_startPosition;
// Skip whitespace preceding this position // Skip whitespace preceding this position
while (editor->characterAt(endOfExpression - 1).isSpace()) while (editor->characterAt(endOfOperator - 1).isSpace())
--endOfExpression; --endOfOperator;
endOfExpression = startOfOperator(editor, endOfExpression, int endOfExpression = startOfOperator(editor, endOfOperator,
&m_completionOperator, &m_completionOperator,
/*want function call =*/ editor->position() == endOfExpression); /*want function call =*/ true);
Core::IFile *file = editor->file(); Core::IFile *file = editor->file();
QString fileName = file->fileName(); QString fileName = file->fileName();
@@ -464,6 +464,11 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_completionOperator = T_SIGNAL; m_completionOperator = T_SIGNAL;
else if (expression.endsWith(QLatin1String("SLOT"))) else if (expression.endsWith(QLatin1String("SLOT")))
m_completionOperator = T_SLOT; m_completionOperator = T_SLOT;
else if (editor->position() != endOfOperator) {
// We don't want a function completion when the cursor isn't at the opening brace
expression.clear();
m_completionOperator = T_EOF_SYMBOL;
}
} }
} }