LanguageClient: properly deactivate documents for closing Clients

Deactivating the documents resets all client specific data and objects
in the document like the formatter or highlighting information.

Fixes an assert in the LanguageClientFormatter.

Change-Id: I7069abb273749ae335fed11010a5055eacaf58b2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-10-18 11:42:26 +02:00
parent 18c00cd381
commit 74cf082ee9

View File

@@ -168,10 +168,10 @@ void LanguageClientManager::clientFinished(Client *client)
const bool unexpectedFinish = client->state() != Client::Shutdown
&& client->state() != Client::ShutdownRequested;
const QList<TextEditor::TextDocument *> &clientDocs
= managerInstance->m_clientForDocument.keys(client);
if (unexpectedFinish) {
if (!PluginManager::isShuttingDown()) {
const QList<TextEditor::TextDocument *> &clientDocs
= managerInstance->m_clientForDocument.keys(client);
if (client->state() == Client::Initialized && client->reset()) {
qCDebug(Log) << "restart unexpectedly finished client: " << client->name() << client;
client->log(
@@ -186,10 +186,14 @@ void LanguageClientManager::clientFinished(Client *client)
}
qCDebug(Log) << "client finished unexpectedly: " << client->name() << client;
client->log(Tr::tr("Unexpectedly finished."));
for (TextEditor::TextDocument *document : clientDocs)
managerInstance->m_clientForDocument.remove(document);
}
}
if (unexpectedFinish || !QTC_GUARD(clientDocs.isEmpty())) {
for (TextEditor::TextDocument *document : clientDocs)
openDocumentWithClient(document, nullptr);
}
deleteClient(client);
if (isShutdownFinished())
emit managerInstance->shutdownFinished();