ClangCodeModel: Fix positioning lightbulbs for diagnostics

Set the diagnostic to the containing code action when generating
refactor markers. This makes sure the light bulb is displayed at the
diagnostic and not the edit location.

Change-Id: I46ac7a19879d2358eb49f5cb1b695ee10a0c682d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2022-05-13 08:35:01 +02:00
parent 1dd2eea25c
commit 4f29bd5613

View File

@@ -1676,8 +1676,10 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams &params)
const ClangdDiagnostic clangdDiagnostic(diagnostic);
const auto codeActions = clangdDiagnostic.codeActions();
if (codeActions && !codeActions->isEmpty()) {
for (const CodeAction &action : *codeActions)
for (CodeAction action : *codeActions) {
action.setDiagnostics({diagnostic});
LanguageClient::updateCodeActionRefactoringMarker(this, action, 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.