forked from qt-creator/qt-creator
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:
@@ -345,10 +345,13 @@ void Client::openDocument(TextEditor::TextDocument *document)
|
|||||||
sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item)));
|
sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item)));
|
||||||
|
|
||||||
const Client *currentClient = LanguageClientManager::clientForDocument(document);
|
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);
|
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);
|
LanguageClientManager::openDocumentWithClient(document, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::sendContent(const IContent &content)
|
void Client::sendContent(const IContent &content)
|
||||||
@@ -878,6 +881,11 @@ void Client::setSupportedLanguage(const LanguageFilter &filter)
|
|||||||
m_languagFilter = filter;
|
m_languagFilter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::setActivateDocumentAutomatically(bool enabled)
|
||||||
|
{
|
||||||
|
m_activateDocAutomatically = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void Client::setInitializationOptions(const QJsonObject &initializationOptions)
|
void Client::setInitializationOptions(const QJsonObject &initializationOptions)
|
||||||
{
|
{
|
||||||
m_initializationOptions = initializationOptions;
|
m_initializationOptions = initializationOptions;
|
||||||
|
@@ -118,6 +118,7 @@ public:
|
|||||||
|
|
||||||
// document synchronization
|
// document synchronization
|
||||||
void setSupportedLanguage(const LanguageFilter &filter);
|
void setSupportedLanguage(const LanguageFilter &filter);
|
||||||
|
void setActivateDocumentAutomatically(bool enabled);
|
||||||
bool isSupportedDocument(const TextEditor::TextDocument *document) const;
|
bool isSupportedDocument(const TextEditor::TextDocument *document) const;
|
||||||
bool isSupportedFile(const Utils::FilePath &filePath, const QString &mimeType) const;
|
bool isSupportedFile(const Utils::FilePath &filePath, const QString &mimeType) const;
|
||||||
bool isSupportedUri(const LanguageServerProtocol::DocumentUri &uri) const;
|
bool isSupportedUri(const LanguageServerProtocol::DocumentUri &uri) const;
|
||||||
@@ -242,6 +243,7 @@ private:
|
|||||||
QSet<TextEditor::IAssistProcessor *> m_runningAssistProcessors;
|
QSet<TextEditor::IAssistProcessor *> m_runningAssistProcessors;
|
||||||
SymbolSupport m_symbolSupport;
|
SymbolSupport m_symbolSupport;
|
||||||
ProgressManager m_progressManager;
|
ProgressManager m_progressManager;
|
||||||
|
bool m_activateDocAutomatically = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LanguageClient
|
} // namespace LanguageClient
|
||||||
|
@@ -566,6 +566,7 @@ Client *BaseSettings::createClient()
|
|||||||
client->setName(Utils::globalMacroExpander()->expand(m_name));
|
client->setName(Utils::globalMacroExpander()->expand(m_name));
|
||||||
client->setSupportedLanguage(m_languageFilter);
|
client->setSupportedLanguage(m_languageFilter);
|
||||||
client->setInitializationOptions(initializationOptions());
|
client->setInitializationOptions(initializationOptions());
|
||||||
|
client->setActivateDocumentAutomatically(true);
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user