summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodecompletion.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-01-26 15:51:14 +0100
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-01-26 15:55:57 +0100
commit8c59160792cd9d1ef4a2273cd6058ad105b92ea5 (patch)
tree61a8d45606de31a8b8b1bede9a13756234603635 /src/plugins/cpptools/cppcodecompletion.cpp
parent9c897b4411477675447b109a41816e93bb8e196c (diff)
downloadqt-creator-8c59160792cd9d1ef4a2273cd6058ad105b92ea5.tar.gz
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.
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r--src/plugins/cpptools/cppcodecompletion.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index 573c9a2546..824b7b4b1c 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -435,15 +435,15 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_startPosition = findStartOfName(editor);
m_completionOperator = T_EOF_SYMBOL;
- int endOfExpression = m_startPosition;
+ int endOfOperator = m_startPosition;
// Skip whitespace preceding this position
- while (editor->characterAt(endOfExpression - 1).isSpace())
- --endOfExpression;
+ while (editor->characterAt(endOfOperator - 1).isSpace())
+ --endOfOperator;
- endOfExpression = startOfOperator(editor, endOfExpression,
- &m_completionOperator,
- /*want function call =*/ editor->position() == endOfExpression);
+ int endOfExpression = startOfOperator(editor, endOfOperator,
+ &m_completionOperator,
+ /*want function call =*/ true);
Core::IFile *file = editor->file();
QString fileName = file->fileName();
@@ -464,6 +464,11 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_completionOperator = T_SIGNAL;
else if (expression.endsWith(QLatin1String("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;
+ }
}
}