From 85cba79cd265788f75a0af000bb9a39a4c2f8597 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 15 Sep 2023 14:10:08 +0200 Subject: [PATCH] ClangCodeModel: fix setting refactoring markers for clangd LanguageClient::updateCodeActionRefactoringMarker overwrites previously set refactoring markers. Fixes: QTCREATORBUG-29493 Change-Id: I156b4e2ff65aed5928251bfea184e093df686818 Reviewed-by: Christian Kandeler --- src/plugins/clangcodemodel/clangdclient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 7c40086f09c..6827471eb2e 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -628,13 +628,14 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms) const int docVersion = documentVersion(uri); if (params.version().value_or(docVersion) != docVersion) return; + QList allCodeActions; for (const Diagnostic &diagnostic : params.diagnostics()) { const ClangdDiagnostic clangdDiagnostic(diagnostic); auto codeActions = clangdDiagnostic.codeActions(); if (codeActions && !codeActions->isEmpty()) { for (CodeAction &action : *codeActions) action.setDiagnostics({diagnostic}); - LanguageClient::updateCodeActionRefactoringMarker(this, *codeActions, uri); + allCodeActions << *codeActions; } else { // We know that there's only one kind of diagnostic for which clangd has // a quickfix tweak, so let's not be wasteful. @@ -644,6 +645,8 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms) requestCodeActions(uri, diagnostic); } } + if (!allCodeActions.isEmpty()) + LanguageClient::updateCodeActionRefactoringMarker(this, allCodeActions, uri); } void ClangdClient::handleDocumentOpened(TextDocument *doc)