Commit 308b0be6 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

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
parent 8062222e
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment