diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-12-14 14:34:57 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-12-16 14:43:57 +0100 |
commit | 308b0be678224623f5cd7131861d546b176e3a47 (patch) | |
tree | 8cb901d8393adad2a4e5cd42fa8fbff654ffdb19 /src/plugins/cpptools/cppcodecompletion.cpp | |
parent | 8062222e0f0031c6a19bb312144af14f70520714 (diff) | |
download | qt-creator-308b0be678224623f5cd7131861d546b176e3a47.tar.gz |
Avoid skipping the closing parenthesis when completing with '('
When the user types '(' then he'll likely also type the matching ')',
in which case skipping the automatic closing parenthesis is annoying
because you would end up with two of them.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodecompletion.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 0f153b43f5..8cf27fd644 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1947,6 +1947,11 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item, QChar t } #endif } else if (! function->isAmbiguous()) { + // When the user typed the opening parenthesis, he'll likely also type the closing one, + // in which case it would be annoying if we put the cursor after the already automatically + // inserted closing parenthesis. + const bool skipClosingParenthesis = typedChar != QLatin1Char('('); + if (completionSettings().m_spaceAfterFunctionName) extraChars += QLatin1Char(' '); extraChars += QLatin1Char('('); @@ -1966,7 +1971,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item, QChar t } // If the function takes no arguments, automatically place the closing parenthesis - if (item.duplicateCount == 0 && ! function->hasArguments()) { + if (item.duplicateCount == 0 && ! function->hasArguments() && skipClosingParenthesis) { extraChars += QLatin1Char(')'); if (endWithSemicolon) { extraChars += semicolon; |