-
Notifications
You must be signed in to change notification settings - Fork 28.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorations flickering on editor change #136241
Comments
This is an interesting example that shows the issue with three different extensions that use decorations with different delays: Screen.Recording.2021-11-01.at.18.12.57.mov(the strikethrough effect is kind of cool though, like it's striking the word through XD) |
You are correct, the current approach to text editor decorations is to clear them when the text model is detached from the code editor (i.e. when switching tabs). Here is how decorations work internally:
I am not quite sure how we could improve things, perhaps by having a "persistent" property or something on these decorations that should survive across detaching / re-attaching a text model to a code editor. |
Thank you very much for the detailed answer @alexdima, I understand your points, I'm giving a heads up to extension developers that I believe may be interested in this. |
One thing that may be changed in any case is the reference example: the problem is made worse because extension developers may be copying a recipe that delays redecoration by 500ms even on editor switch. |
@memeplex I agree that the example is flawed, as it artificially delays computing decorations when switching editors. Would you be willing to contribute a PR to improve it? |
Sure @alexdima I'm pretty busy right now but I'll give it a try in a few days. |
@alexdima please see https://github.com/microsoft/vscode-extension-samples/pull/535/files. I'm not sure if there is any advantage in using a timeout of 0 (vs directly calling the refresh as I did). |
Does calling setDecorations immediately upon active editor change [1] actually eliminate the 500ms delay? If I understand the exchange correctly, and if my own testing is reliable, the 500ms or so delay appears to be unavoidable, at least as things currently stand? [1] as in:
|
Also, I noticed that vscode's own inlay parameter hints (which I've read are also implemented using decorations) do persist across active editor change, and are unaffected by the 500ms delay. See this gif demonstration and notice how the 'num' inlay parameter hint in the func() call persists across editor changes. Is there a way for extension developers to simulate the effect of persistent decorations? |
A |
Does this issue occur when all extensions are disabled?: Yes
I've recently been trying to optimize an extension that decorates
[[...]]
wikilinks in markdown documents. Every time I switched between editors a very noticeable flickering happened because of the syntax rehighlighting of the editor and, not so shortly after that, a delayed repainting of decorations. I checked other similar extensions and the pattern was always the same. It's even suggested in this "official" example: https://github.com/microsoft/vscode-extension-samples/blob/main/decorator-sample/src/extension.ts. There are two problems:The second point is likely the hard one because it might be due to a more structural limit of the design. Why is VSCode triggering document-wise updates of decorations in unchanged documents? From the perspective of the extension author, is there any way to do that update incrementally, some knowledge of damaged/exposed chunks?
N.B. in the above cases extending the syntax was also problematic, for example because of the need to distinctively decorate valid and invalid links. Even if the syntax extension approach were effective here, the point still stands that decorations seem ill-suited for anything but small documents and even in those documents they produce visual artifacts on editor switching.
The text was updated successfully, but these errors were encountered: