Clang: Do not show completions after comma in initializer list

Appends 0852f889d1.

Do not automatically show global completion when initializer list
does not have a type, e.g. auto foo = {{},<cursor>};

Change-Id: I233fef71c60bb79211000df70bf5b04fa2d9df37
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-12 14:29:15 +01:00
parent 1b0cba38dd
commit 82d6d20acb
2 changed files with 7 additions and 2 deletions

View File

@@ -264,7 +264,7 @@ int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
break; break;
} else if (tk.is(T_LPAREN) || tk.is(T_LBRACE)) { } else if (tk.is(T_LPAREN) || tk.is(T_LBRACE)) {
return scanner.startPosition() + tk.utf16charsBegin(); return scanner.startPosition() + tk.utf16charsBegin();
} else if (tk.is(T_RPAREN)) { } else if (tk.is(T_RPAREN) || tk.is(T_RBRACE)) {
int matchingBrace = scanner.startOfMatchingBrace(index); int matchingBrace = scanner.startOfMatchingBrace(index);
if (matchingBrace == index) // If no matching brace found if (matchingBrace == index) // If no matching brace found

View File

@@ -110,6 +110,8 @@ int ClangCompletionContextAnalyzer::startOfFunctionCall(int endOfOperator) const
functionNameSelector.setPosition(functionNameStart); functionNameSelector.setPosition(functionNameStart);
functionNameSelector.setPosition(index, QTextCursor::KeepAnchor); functionNameSelector.setPosition(index, QTextCursor::KeepAnchor);
const QString functionName = functionNameSelector.selectedText().trimmed(); const QString functionName = functionNameSelector.selectedText().trimmed();
if (functionName.isEmpty() && m_completionOperator == T_LBRACE)
return endOfOperator;
return functionName.isEmpty() ? -1 : functionNameStart; return functionName.isEmpty() ? -1 : functionNameStart;
} }
@@ -139,7 +141,10 @@ void ClangCompletionContextAnalyzer::handleCommaInFunctionCall()
const int start = expressionUnderCursor.startOfFunctionCall(textCursor); const int start = expressionUnderCursor.startOfFunctionCall(textCursor);
m_positionEndOfExpression = start; m_positionEndOfExpression = start;
m_positionForProposal = start + 1; // After '(' of function call m_positionForProposal = start + 1; // After '(' of function call
m_completionOperator = T_LPAREN; if (m_interface->characterAt(start) == '(')
m_completionOperator = T_LPAREN;
else
m_completionOperator = T_LBRACE;
} }
} }