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); hideDiagnostics(document);
resetAssistProviders(document); resetAssistProviders(document);
document->setFormatter(nullptr); document->setFormatter(nullptr);
if (TextEditor::SyntaxHighlighter *highlighter = document->syntaxHighlighter()) if (m_serverCapabilities.semanticHighlighting().has_value()) {
highlighter->clearAllExtraFormats(); if (TextEditor::SyntaxHighlighter *highlighter = document->syntaxHighlighter())
highlighter->clearAllExtraFormats();
}
for (Core::IEditor *editor : Core::DocumentModel::editorsForDocument(document)) { for (Core::IEditor *editor : Core::DocumentModel::editorsForDocument(document)) {
if (auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor)) if (auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor))
textEditor->editorWidget()->removeHoverHandler(&m_hoverHandler); textEditor->editorWidget()->removeHoverHandler(&m_hoverHandler);

View File

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