From d603654acaca2377483ecf241e77af6d7c0c2302 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 12 Jul 2021 11:24:19 +0200 Subject: [PATCH] ClangdClient: Do not close temporarily opened files ... if they have been properly opened in the meantime. This fixes the problem that when a file was opened indirectly via "Go to definition", the didClose message for the file that we temporarily opened to search for overrides sometimes came in after the "regular" opening of the file. As a result, such files were not actually in clangd's open documents set, and no functionality was available for them (e.g. F2 on a symbol would do nothing). Also remove a left-over related declaration. Change-Id: I9fc85d95595cb38a8d92e3f46505b9c514537d21 Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdclient.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index ae1e29a8eb8..c180710a340 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -540,8 +540,10 @@ public: void closeTempDocuments() { - for (const Utils::FilePath &fp : qAsConst(openedFiles)) - q->closeExtraFile(fp); + for (const Utils::FilePath &fp : qAsConst(openedFiles)) { + if (!q->documentForFilePath(fp)) + q->closeExtraFile(fp); + } openedFiles.clear(); } @@ -690,7 +692,6 @@ public: void sendGotoImplementationRequest(const Utils::Link &link); void handleGotoImplementationResult(const GotoImplementationRequest::Response &response); void handleDocumentInfoResults(); - void closeTempDocuments(); void handleDeclDefSwitchReplies();