forked from qt-creator/qt-creator
LanguageClient: postpone outline update until documents are opened
Skip the outline update in the initialize callback since no documents are opened at that point in time and LanguageClientOutlineWidgetFactory::supportsEditor will always return false. The update will be triggered in Client::activateDocument instead. Change-Id: Ib26115c2344f7a424c31ce09b751a1d711a93aae Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -843,6 +843,8 @@ void Client::activateDocument(TextEditor::TextDocument *document)
|
||||
document->setFormatter(new LanguageClientFormatter(document, this));
|
||||
for (Core::IEditor *editor : Core::DocumentModel::editorsForDocument(document)) {
|
||||
updateEditorToolBar(editor);
|
||||
if (editor == Core::EditorManager::currentEditor())
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
if (auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor)) {
|
||||
TextEditor::TextEditorWidget *widget = textEditor->editorWidget();
|
||||
widget->addHoverHandler(&d->m_hoverHandler);
|
||||
@@ -1481,7 +1483,7 @@ void Client::setQuickFixAssistProvider(LanguageClientQuickFixProvider *provider)
|
||||
|
||||
bool Client::supportsDocumentSymbols(const TextEditor::TextDocument *doc) const
|
||||
{
|
||||
if (!doc)
|
||||
if (!doc || !reachable())
|
||||
return false;
|
||||
DynamicCapabilities dc = dynamicCapabilities();
|
||||
if (dc.isRegistered(DocumentSymbolsRequest::methodName).value_or(false)) {
|
||||
@@ -1981,14 +1983,6 @@ void ClientPrivate::initializeCallback(const InitializeRequest::Response &initRe
|
||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
||||
m_state = Client::Initialized;
|
||||
q->sendMessage(InitializeNotification(InitializedParams()));
|
||||
std::optional<std::variant<bool, WorkDoneProgressOptions>> documentSymbolProvider
|
||||
= q->capabilities().documentSymbolProvider();
|
||||
if (documentSymbolProvider.has_value()) {
|
||||
if (!std::holds_alternative<bool>(*documentSymbolProvider)
|
||||
|| std::get<bool>(*documentSymbolProvider)) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
}
|
||||
|
||||
q->updateConfiguration(m_configuration);
|
||||
|
||||
|
||||
@@ -131,8 +131,11 @@ void LanguageClientManager::clientFinished(Client *client)
|
||||
client->log(
|
||||
tr("Unexpectedly finished. Restarting in %1 seconds.").arg(restartTimeoutS));
|
||||
QTimer::singleShot(restartTimeoutS * 1000, client, [client]() { client->start(); });
|
||||
for (TextEditor::TextDocument *document : clientDocs)
|
||||
for (TextEditor::TextDocument *document : clientDocs) {
|
||||
client->deactivateDocument(document);
|
||||
if (Core::EditorManager::currentEditor()->document() == document)
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
return;
|
||||
}
|
||||
qCDebug(Log) << "client finished unexpectedly: " << client->name() << client;
|
||||
@@ -401,8 +404,9 @@ void LanguageClientManager::openDocumentWithClient(TextEditor::TextDocument *doc
|
||||
client->openDocument(document);
|
||||
else
|
||||
client->activateDocument(document);
|
||||
} else if (Core::EditorManager::currentEditor()->document() == document) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
|
||||
void LanguageClientManager::logJsonRpcMessage(const LspLogMessage::MessageSender sender,
|
||||
|
||||
Reference in New Issue
Block a user