expose only the positions of those brackets colored by native bracket pair colorization
See original GitHub issueQuestion: I know exposing tokens to extensions is a headache, but is it now possible and non-headache to expose only the positions of those brackets colored by native bracket pair colorization?
like this:
{type: "{" | "}" | "(" | ")" | "[" | "]"; line: number; column: number; }[]
or like this:
{type: "{" | "}" | "(" | ")" | "[" | "]"; globalStringIndex: number; }[]
No tree structure needed, just a simple array of positions. It will be super huge speed upgrade for Blockman (already 19k installs).
_Originally posted by @leodevbro in https://github.com/microsoft/vscode/issues/128465#issuecomment-900604355_
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Bracket pair colorization 10000x faster - Visual Studio Code
Bracket pair colorization is all about quickly determining all brackets and their (absolute) nesting level in the viewport. The viewport can be ...
Read more >Native Bracket Pair Colourization in VS Code
Configure native bracket pair colourization All colors are themeable and up to six colors can be configured. If playback doesn't begin shortly, ...
Read more >Adding color to bracket pairs - Visual Studio Blog
We call it Rainbow Braces and the first iteration adds basic colorization to curly brackets, square brackets, and parentheses (see image above).
Read more >VS Code — Native Bracket Pair Colorization - YouTube
In this video, we're gonna be looking at how to enable a newly added VS Code feature that allows us to color parentheses,...
Read more >Making bracket pair colorization faster - Hacker News
The blog post does a great job of describing why bracket colorization isn't appropriate for the plug-in architecture anyway.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case of Blockman extension, I guess currently it works basically that way, when typing text on keyboard Blockman cannot analyze updated content quickly enough to keep up the changes in real time, so it deals with timers (It’s like a refresh rate or frames per second in video games. If refresh rate is low, the game will have less CPU/GPU overload and will be more performant). On each text change event, Blockman starts re-analyzing the file after
t
seconds. If we set thet
to be0
seconds, the editor UI will most likely freeze during typing some text on the keyboard, so, that’s why the default time is1.2
seconds. The freezing is still noticeable during typing, but it’s not a deal breaker for many coders because it feels rare and short.Note: the timer is triggered only for the last change event and is not triggered on every event during the 1.2 seconds, so it will not get overloaded and bounced.
So, yeah, with Blockman, if text changes during the ongoing analyzing/rendering process, the blocks will be rendered for the old text, so it will look incorrect visually, but Blockman detects the change events and re-renders the blocks again with the new content. So the blocks finally are being rendered correctly. So, I guess the the blocks appear incorrect for about 1 second (average time) when working on a 5,000 line file, but if it will have access to the native tokens of brackets, I think this average time will go down to maybe 0.1 seconds, and so it will feel more comfy.
The problem is this:
How can we prevent someone from doing this? The issue here is that
getBracketPairs
is async. When the call returns, the text buffer could have already been modified and not agree withcontent
anymore.