LanguageClient: do not auto-assign documents to all clients

Only assign documents to a client if the client was started by a
setting. Programatically started clients should handle assigned
documents manually.

Change-Id: I192c4c011a48e0406f267d3cab3c860f740ddad7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2021-04-20 11:40:24 +02:00
parent 3d1ad9db60
commit d66b410adb
3 changed files with 13 additions and 2 deletions

View File

@@ -345,10 +345,13 @@ void Client::openDocument(TextEditor::TextDocument *document)
sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item)));
const Client *currentClient = LanguageClientManager::clientForDocument(document);
if (currentClient == this) // this is the active client for the document so directly activate it
if (currentClient == this) {
// this is the active client for the document so directly activate it
activateDocument(document);
else if (currentClient == nullptr) // there is no client for this document so assign it to this server
} else if (m_activateDocAutomatically && currentClient == nullptr) {
// there is no client for this document so assign it to this server
LanguageClientManager::openDocumentWithClient(document, this);
}
}
void Client::sendContent(const IContent &content)
@@ -878,6 +881,11 @@ void Client::setSupportedLanguage(const LanguageFilter &filter)
m_languagFilter = filter;
}
void Client::setActivateDocumentAutomatically(bool enabled)
{
m_activateDocAutomatically = enabled;
}
void Client::setInitializationOptions(const QJsonObject &initializationOptions)
{
m_initializationOptions = initializationOptions;