LanguageClient: assign document to correct client

If a server is setup to start per project we want to open files of a
project in the matching server by default.

Change-Id: Ie266fd858420acd75b7a1fd45be7bee2b06460aa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-02-23 08:38:39 +01:00
parent 9cc234fbdf
commit 01caf29221

View File

@@ -472,13 +472,17 @@ void LanguageClientManager::documentOpened(Core::IDocument *document)
continue;
// check whether we already have a client running for this project
if (Utils::findOrDefault(clients,
[project](const QPointer<Client> &client) {
return client->project() == project;
})) {
continue;
Client *clientForProject = Utils::findOrDefault(clients,
[project](Client *client) {
return client->project()
== project;
});
if (!clientForProject) {
clientForProject = startClient(setting, project);
clients << clientForProject;
}
clients << startClient(setting, project);
QTC_ASSERT(clientForProject, continue);
openDocumentWithClient(textDocument, clientForProject);
}
} else if (setting->m_startBehavior == BaseSettings::RequiresFile && clients.isEmpty()) {
clients << startClient(setting);