LanguageClient: update semantic highlighting only if server supports it

Task-number: QTCREATORBUG-23599
Change-Id: I76c804b51362ad6ab2aecf0631a16289a33e4810
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-02-17 12:57:59 +01:00
parent 909cb3859b
commit b9af9881a9
2 changed files with 10 additions and 6 deletions

View File

@@ -392,8 +392,10 @@ void Client::deactivateDocument(TextEditor::TextDocument *document)
hideDiagnostics(document);
resetAssistProviders(document);
document->setFormatter(nullptr);
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<TextEditor::BaseTextEditor *>(editor))
textEditor->editorWidget()->removeHoverHandler(&m_hoverHandler);

View File

@@ -151,11 +151,13 @@ void applyHighlight(TextEditor::TextDocument *doc,
}
}
if (capabilities.semanticHighlighting().has_value()) {
TextEditor::SemanticHighlighter::setExtraAdditionalFormats(
doc->syntaxHighlighter(),
results,
scopesToFormatHash(highlightScopes(capabilities), doc->fontSettings()));
}
}
} // namespace SemanticHighligtingSupport
} // namespace LanguageClient