forked from qt-creator/qt-creator
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 <christian.kandeler@qt.io>
This commit is contained in:
@@ -325,15 +325,11 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Acquaint the client with all open C++ documents for this project.
|
// Acquaint the client with all open C++ documents for this project.
|
||||||
ClangdClient * const fallbackClient = clientForProject(nullptr);
|
|
||||||
bool hasDocuments = false;
|
bool hasDocuments = false;
|
||||||
for (TextEditor::BaseTextEditor * const editor : allCppEditors()) {
|
for (TextEditor::BaseTextEditor * const editor : allCppEditors()) {
|
||||||
if (!project->isKnownFile(editor->textDocument()->filePath()))
|
if (!project->isKnownFile(editor->textDocument()->filePath()))
|
||||||
continue;
|
continue;
|
||||||
if (fallbackClient && fallbackClient->documentOpen(editor->textDocument()))
|
LanguageClientManager::openDocumentWithClient(editor->textDocument(), client);
|
||||||
fallbackClient->closeDocument(editor->textDocument());
|
|
||||||
if (!client->documentOpen(editor->textDocument()))
|
|
||||||
client->openDocument(editor->textDocument());
|
|
||||||
ClangEditorDocumentProcessor::clearTextMarks(editor->textDocument()->filePath());
|
ClangEditorDocumentProcessor::clearTextMarks(editor->textDocument()->filePath());
|
||||||
hasDocuments = true;
|
hasDocuments = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user