LanguageClient: Do not update semantic tokens on every document update

Due to the potential cost of the re-highlighting procedure, we'd like to
delay the semantic tokens update request to a time where the new token
information won't get invalidated right away due to further document
changes. While the document updates in principle have such a delay
already, it is often "sabotaged", for instance due to auto-completion
requests which require the server to know the current document contents
right away.
Therefore, we request new semantic tokens along with a document update
only if it's the "regular" delayed one, and otherwise add an additional
delay.

Change-Id: I074647d1cdfdbcc6aa5fc5ec2a2d5ae6ccd493ba
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-14 13:16:43 +02:00
parent 2b09c81682
commit 1206ac03cc
2 changed files with 16 additions and 5 deletions

View File

@@ -228,7 +228,9 @@ private:
void removeDiagnostics(const LanguageServerProtocol::DocumentUri &uri);
void resetAssistProviders(TextEditor::TextDocument *document);
void sendPostponedDocumentUpdates();
enum class SemanticTokensUpdateMode { Now, Delayed };
void sendPostponedDocumentUpdates(SemanticTokensUpdateMode semanticTokensUpdateMode);
void updateCompletionProvider(TextEditor::TextDocument *document);
void updateFunctionHintProvider(TextEditor::TextDocument *document);