From 4f29bd56131a22c8c71595f4ee5bd551b7273e7d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 13 May 2022 08:35:01 +0200 Subject: [PATCH] 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 --- src/plugins/clangcodemodel/clangdclient.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index a241d1c63e5..8a8fc4ccc8b 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -1676,8 +1676,10 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms) 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.