-
Notifications
You must be signed in to change notification settings - Fork 0
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
Flickering when changing #2
Comments
Thank you so much! This was my first TypeScript project, and it was an uphill battle to figure it out. I actually wrote this as a personal requirement to use VS Code over Sublime Text where I had a similar (now broken) version of a similar plugin. I'm not sure what you mean by flicker. Can you explain in more detail? Do you mean flicker because is it's recalculating colors on the fly and only once per code window. |
Are we the same person apart from the fact I'm coming from Kdevelop :P?
I think so! When I press Ctrl+S, for a brief instant, all the color reset before it becomes colorful again. My repo doesn't do that, so there might be some logic there for it. I think I have added a special buffer for it, but it was a while back and I don't remember. |
I pushed up an update ( It might not fix the flickering, but it did fix a couple other issues:
I completely refactored eventing logic, but I have yet to get back into the colorizing code. It gets pretty complex because I have to load TextMate-style configs for semantic colors not provided by VSCode. |
Ok, in large files, I see the flickering now. No, it's not gone. It's related to the fact that I'm re-coloring everything only after removing the old colors. There's probably an optimization I could do to leave the old colors, add new ones, and remove the old ones after. |
For me the colors are still flashing for every keystroke I make. |
I have a I'll have to make it configurable. I based it off my own typing speed, and what I expected to see. |
I’m pretty sure I’m doing more than 10 keystrokes per second. For me it almost looks like no debouncing is happening. I have double-checked that I’m on |
Hmm... Before, it would debounce at v3.3 has debouncing per editor window for all update events, and they now happen at |
Screencast_20231121_094557.webmHere is a video of what I am observing. The file has a few hundred lines but is otherwise not complicated. What I see is:
I think what happens is that even though I’m fast there might be pauses that are longer than 100ms. The problem is then that the redraw is triggered, but additional redraws might be triggered while the one is happening. So they seem to queue up. Also the editor starts to lag. My keystrokes are delayed leading to more pauses of >100ms and more redraws queuing up. |
This fixes a bug related to flickering when clicking a previously-colored text editor window. #2
ProblemI was removing all colors and then colorizing again. Source: https://github.com/Sawtaytoes/vscode-colormate/blob/v3.3.3/src/colorize.ts#L406-L408 SolutionRemove previous colors only after coloring. This prevents the flashing that occurs in already-colored text editors. Source: https://github.com/Sawtaytoes/vscode-colormate/blob/v3.3.4/src/colorize.ts#L459-L466 This also fixes some bad code where mutations were occurring in the removal function. Not sure why I wrote it that way 🤷♂️. |
Ah, I didn't see your video until now.
I'm wondering if the token scopes are changing while you type, and that's why it's doing the flashy thing. If the token scopes were removed and then re-added, it would first remove all colors, then re-add them. |
I was right. Part of the flashiness is from the I had trouble capturing this because it happens so quickly, but as you can see here, when I press This is what it should look like: Raising the debounce to Any suggestions on how to fix this other than modifying the debounce would be greatly appreciated! TextMate grammars are correct even when VSCode's scopes are not. Solution 1We could add TextMate grammar highlights on top of VSCode scope highlights, but that poses an issue. For some reason, the WASM runner for TextMate grammars crashes after some time of VSCode being open. I think it's related to too many instances of it running at the same time. I have put in one caching solution so far, but all that does is temporarily mitigate it. Eventually, it'll run out of memory again and be completely broken after that. I have yet to figure out a solution for that issue, but if I did, we could instead rely on TextMate grammars and wouldn't have the flashiness. Solution 2I'm wondering if there's another way to check if VSCode is still processing scopes and halt the colorization until it's done figuring them out. Since it's removing scopes when we go to colorize, that's why we see flashiness happening. |
I'm the author of a similar extension and some of my users have pointed to this extension :).
I tried it and I like it, it's great! One thing that I have observed is that mine doesn't flicker, and with yours it does on my machine. I'm not sure what I did that fixed, but if you feel like looking into the code and integrating it into colormate, that would be great! Your code, as far as I can see, works better on large projects, so I would love to switch to yours if the flicker is resolved :)
The text was updated successfully, but these errors were encountered: