From b9af9881a9024732e738f05fbaa7375f69eb47e5 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 17 Feb 2020 12:57:59 +0100 Subject: [PATCH] LanguageClient: update semantic highlighting only if server supports it Task-number: QTCREATORBUG-23599 Change-Id: I76c804b51362ad6ab2aecf0631a16289a33e4810 Reviewed-by: Christian Stenger --- src/plugins/languageclient/client.cpp | 6 ++++-- .../languageclient/semantichighlightsupport.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index cafad5f89cc..5d62cdfeb9a 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -392,8 +392,10 @@ void Client::deactivateDocument(TextEditor::TextDocument *document) hideDiagnostics(document); resetAssistProviders(document); document->setFormatter(nullptr); - if (TextEditor::SyntaxHighlighter *highlighter = document->syntaxHighlighter()) - highlighter->clearAllExtraFormats(); + if (m_serverCapabilities.semanticHighlighting().has_value()) { + if (TextEditor::SyntaxHighlighter *highlighter = document->syntaxHighlighter()) + highlighter->clearAllExtraFormats(); + } for (Core::IEditor *editor : Core::DocumentModel::editorsForDocument(document)) { if (auto textEditor = qobject_cast(editor)) textEditor->editorWidget()->removeHoverHandler(&m_hoverHandler); diff --git a/src/plugins/languageclient/semantichighlightsupport.cpp b/src/plugins/languageclient/semantichighlightsupport.cpp index 59b415455f7..8f333ea1838 100644 --- a/src/plugins/languageclient/semantichighlightsupport.cpp +++ b/src/plugins/languageclient/semantichighlightsupport.cpp @@ -151,10 +151,12 @@ void applyHighlight(TextEditor::TextDocument *doc, } } - TextEditor::SemanticHighlighter::setExtraAdditionalFormats( - doc->syntaxHighlighter(), - results, - scopesToFormatHash(highlightScopes(capabilities), doc->fontSettings())); + if (capabilities.semanticHighlighting().has_value()) { + TextEditor::SemanticHighlighter::setExtraAdditionalFormats( + doc->syntaxHighlighter(), + results, + scopesToFormatHash(highlightScopes(capabilities), doc->fontSettings())); + } } } // namespace SemanticHighligtingSupport