question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Semantic highlighting flickers

See original GitHub issue

I’ve tried new semantic highlighting API in rust-analyzer (which was implemented by @kjeremy). I am super excited to see this feature finally in the LSP!

However, test drive shows this flickering:

flicker

I am not exactly sure, but I think the reason here is content modifies errors:

[Trace - 4:17:49 PM] Received response 'textDocument/semanticTokens - (437)' in 15ms. Request failed: content modified (-32801).

The editor asks for highlights, and then continues with sending modifications. Server than cancels the in-flight highlighting request. This causes the provider to return undefined, and that apparently clears the previous highlights. Because user continues typing, the highlighting is not re-applied until the user stops and the server is able to catch up.

It seems like the better behavior in this case is to just shift previous highlighting ranges, instead of clearing them. Not sure if this something to be fixed in vscode-languageserver-node, vscode itself, or the API for SemanticTokensProvider.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:36 (36 by maintainers)

github_iconTop GitHub Comments

1reaction
alexdimacommented, Mar 5, 2020

@jrieken @dbaeumer Here is an idea. Currently, when a request is canceled by the client, we kind of expect and ignore (in error telemetry, etc.) any error with the message Canceled.

So what if we just extend this and allow that a Canceled error could be thrown even when the cancellation token is not triggered by the client… Then a server side cancelation could be detected by checking if the error is Canceled and if the cancelation token is not set.

1reaction
alexdimacommented, Mar 4, 2020

I don’t think vscode-languageserver-node can run a retry loop.

The VS Code request clearly expects the reply for a certain project state, the project state at which the request was made.

The whole point of the server canceling is that the server believes it makes no sense to answer the request at that certain state and the client should recreate a request at a new project state. This is nothing vscode-languageserver-node can do.

For example, for semantic tokens, when a request is made, text buffer edits are collected, such that when the response comes back, the response is adjusted against the user edits that occurred in the meantime. When a request is canceled (completed via a busy error), the collected text buffer edits are dropped and a new request is made, which is expected to return results at that new state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax highlighting flickering when formatting file : r/neovim
Semantic highlighting from the LSP server probably. It's cleared after formatting due to buffer contents changing, and then it takes a while for ......
Read more >
Syntax highlighting "blinks" with semantic error markers
The main problem was that each message produced by IParseController.parse() was directly applied as an "annotation model" update, via calls to ...
Read more >
Adding Semantic Highlighting to comments in CEditor in Eclipse
So I want to perform semantic highlighting of comments in CEditor. ... Previous Topic: Flicker when dragging and dropping a text editor ...
Read more >
January 2021 (version 1.53) - Visual Studio Code
Native support for semantic highlighting, instead of using a TypeScript service plugin. ... fix #115050 flickering tabs when wrapped PR #115273.
Read more >
Please Highlight this Area and Add your Main Title - Psychology
The results showed larger measured visual field extent for flickering stimuli ... Using a simple semantic interference task to assess suppression skill, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found