forked from qt-creator/qt-creator
LanguageClient: Fix restarting server that needs a project
Do not open the server for every open document that belongs to that server and assign the documents to the correct servers. Change-Id: I88a743489e7e4b396a112ad772926e90b22626f3 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -253,13 +253,24 @@ void LanguageClientManager::applySettings()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BaseSettings::RequiresProject: {
|
case BaseSettings::RequiresProject: {
|
||||||
for (Core::IDocument *doc : Core::DocumentModel::openedDocuments()) {
|
const QList<Core::IDocument *> &openedDocuments = Core::DocumentModel::openedDocuments();
|
||||||
if (setting->m_languageFilter.isSupported(doc)) {
|
QHash<ProjectExplorer::Project *, Client *> clientForProject;
|
||||||
const Utils::FilePath filePath = doc->filePath();
|
for (Core::IDocument *document : openedDocuments) {
|
||||||
|
auto textDocument = qobject_cast<TextEditor::TextDocument *>(document);
|
||||||
|
if (!textDocument || !setting->m_languageFilter.isSupported(textDocument))
|
||||||
|
continue;
|
||||||
|
const Utils::FilePath filePath = textDocument->filePath();
|
||||||
for (ProjectExplorer::Project *project :
|
for (ProjectExplorer::Project *project :
|
||||||
ProjectExplorer::SessionManager::projects()) {
|
ProjectExplorer::SessionManager::projects()) {
|
||||||
if (project->isKnownFile(filePath))
|
if (project->isKnownFile(filePath)) {
|
||||||
startClient(setting, project);
|
Client *client = clientForProject[project];
|
||||||
|
if (!client) {
|
||||||
|
client = startClient(setting, project);
|
||||||
|
if (!client)
|
||||||
|
continue;
|
||||||
|
clientForProject[project] = client;
|
||||||
|
}
|
||||||
|
client->openDocument(textDocument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user