forked from qt-creator/qt-creator
LanguageClient: fix opening docs after always on client settings change
Change-Id: I16dd336278071ae3175971f3044c8556f20da993 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -310,37 +310,29 @@ void LanguageClientManager::applySettings(BaseSettings *setting)
|
|||||||
managerInstance->m_clientForDocument.remove(document);
|
managerInstance->m_clientForDocument.remove(document);
|
||||||
if (!setting->isValid() || !setting->m_enabled)
|
if (!setting->isValid() || !setting->m_enabled)
|
||||||
return;
|
return;
|
||||||
switch (setting->m_startBehavior) {
|
if (setting->m_startBehavior == BaseSettings::AlwaysOn || BaseSettings::RequiresFile) {
|
||||||
case BaseSettings::AlwaysOn: {
|
auto ensureClient = [setting, client = static_cast<Client *>(nullptr)]() mutable {
|
||||||
Client *client = startClient(setting);
|
if (!client)
|
||||||
for (TextEditor::TextDocument *document : std::as_const(documents))
|
client = startClient(setting);
|
||||||
managerInstance->m_clientForDocument[document] = client;
|
return client;
|
||||||
break;
|
};
|
||||||
}
|
if (setting->m_startBehavior == BaseSettings::AlwaysOn)
|
||||||
case BaseSettings::RequiresFile: {
|
ensureClient();
|
||||||
Client *client = nullptr;
|
|
||||||
for (TextEditor::TextDocument *previousDocument : std::as_const(documents)) {
|
for (TextEditor::TextDocument *previousDocument : std::as_const(documents)) {
|
||||||
if (setting->m_languageFilter.isSupported(previousDocument)) {
|
if (setting->m_languageFilter.isSupported(previousDocument))
|
||||||
if (!client)
|
openDocumentWithClient(previousDocument, ensureClient());
|
||||||
client = startClient(setting);
|
|
||||||
openDocumentWithClient(previousDocument, client);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const QList<Core::IDocument *> &openedDocuments = Core::DocumentModel::openedDocuments();
|
const QList<Core::IDocument *> &openedDocuments = Core::DocumentModel::openedDocuments();
|
||||||
for (Core::IDocument *document : openedDocuments) {
|
for (Core::IDocument *document : openedDocuments) {
|
||||||
if (documents.contains(document))
|
if (documents.contains(document))
|
||||||
continue; // already handled above
|
continue; // already handled above
|
||||||
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
|
if (auto textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
|
||||||
if (setting->m_languageFilter.isSupported(document)) {
|
if (setting->m_languageFilter.isSupported(document))
|
||||||
if (!client)
|
ensureClient()->openDocument(textDocument);
|
||||||
client = startClient(setting);
|
|
||||||
client->openDocument(textDocument);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
} else if (setting->m_startBehavior == BaseSettings::RequiresProject) {
|
||||||
}
|
|
||||||
case BaseSettings::RequiresProject: {
|
|
||||||
const QList<Core::IDocument *> &openedDocuments = Core::DocumentModel::openedDocuments();
|
const QList<Core::IDocument *> &openedDocuments = Core::DocumentModel::openedDocuments();
|
||||||
QHash<ProjectExplorer::Project *, Client *> clientForProject;
|
QHash<ProjectExplorer::Project *, Client *> clientForProject;
|
||||||
for (Core::IDocument *document : openedDocuments) {
|
for (Core::IDocument *document : openedDocuments) {
|
||||||
@@ -362,10 +354,6 @@ void LanguageClientManager::applySettings(BaseSettings *setting)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user