From dc40af5fa57f6ed5cfd9cfecb3d8f09e8de726f8 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 1 Sep 2021 15:31:58 +0200 Subject: [PATCH] Clangd: fix opening document with client for project Using LanguageClientManager::openDocumentWithClient function to assign a document to a specific server. This function also takes care of deactivating the document for the old client and opens it if necessary in the new client. Fixes: QTCREATORBUG-26205 Change-Id: I3c3a5fbcd3d07c2e492ebffdf7870e4d2cb517d4 Reviewed-by: Christian Kandeler --- src/plugins/clangcodemodel/clangmodelmanagersupport.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index bb662db8593..285aa864d42 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -325,15 +325,11 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr return; // Acquaint the client with all open C++ documents for this project. - ClangdClient * const fallbackClient = clientForProject(nullptr); bool hasDocuments = false; for (TextEditor::BaseTextEditor * const editor : allCppEditors()) { if (!project->isKnownFile(editor->textDocument()->filePath())) continue; - if (fallbackClient && fallbackClient->documentOpen(editor->textDocument())) - fallbackClient->closeDocument(editor->textDocument()); - if (!client->documentOpen(editor->textDocument())) - client->openDocument(editor->textDocument()); + LanguageClientManager::openDocumentWithClient(editor->textDocument(), client); ClangEditorDocumentProcessor::clearTextMarks(editor->textDocument()->filePath()); hasDocuments = true; }