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