Commit 0a99fef5 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Avoid automatically inserting unwanted closing parentheses

This is for the case of function overloads where one overload takes no
parameters. Solved by keeping track of the duplicate count.

Done with Roberto Raggi.
parent ece7c9af
......@@ -1224,8 +1224,9 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
extraChars += QLatin1Char('(');
// If the function takes no arguments, automatically place the closing parenthesis
if (function->argumentCount() == 0 || (function->argumentCount() == 1 &&
function->argumentAt(0)->type()->isVoidType())) {
if (item.m_duplicateCount == 0 && (function->argumentCount() == 0 ||
(function->argumentCount() == 1 &&
function->argumentAt(0)->type()->isVoidType()))) {
extraChars += QLatin1Char(')');
// If the function doesn't return anything, automatically place the semicolon,
......
......@@ -186,6 +186,8 @@ QList<CompletionItem> CompletionSupport::getCompletions() const
if (item.m_text != lastKey) {
uniquelist.append(item);
lastKey = item.m_text;
} else {
uniquelist.last().m_duplicateCount++;
}
}
......
......@@ -46,6 +46,7 @@ struct CompletionItem
{
CompletionItem(ICompletionCollector *collector = 0)
: m_relevance(0),
m_duplicateCount(0),
m_collector(collector)
{ }
......@@ -60,6 +61,7 @@ struct CompletionItem
QIcon m_icon;
QVariant m_data;
int m_relevance;
int m_duplicateCount;
ICompletionCollector *m_collector;
};
......
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