LanguageClient: Improve refactoring markers

Clicking the lightbulb should bring up a menu if and only if there is
more than one possible action for this location.
Amends 089e1edcbf.

Change-Id: I45348ed4fbf9b3f32e19bbe17f0c2c030ecd24ed
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-05-17 12:34:00 +02:00
parent 54d4c4db62
commit 5d615e916f
4 changed files with 52 additions and 39 deletions

View File

@@ -1693,12 +1693,11 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams &params)
return;
for (const Diagnostic &diagnostic : params.diagnostics()) {
const ClangdDiagnostic clangdDiagnostic(diagnostic);
const auto codeActions = clangdDiagnostic.codeActions();
auto codeActions = clangdDiagnostic.codeActions();
if (codeActions && !codeActions->isEmpty()) {
for (CodeAction action : *codeActions) {
for (CodeAction &action : *codeActions)
action.setDiagnostics({diagnostic});
LanguageClient::updateCodeActionRefactoringMarker(this, action, uri);
}
LanguageClient::updateCodeActionRefactoringMarker(this, *codeActions, uri);
} else {
// We know that there's only one kind of diagnostic for which clangd has
// a quickfix tweak, so let's not be wasteful.