microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.56k stars 28.13k forks source link

Bracket colorization w/ semantic tokens #149552

Open arcanis opened 2 years ago

arcanis commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes

Semantic token providers cannot influence the new bracket colorization. For instance, even if we tell VSCode a comment token is located on a given range, VSCode will still colorize the brackets:

image

The only way to "silence" them is to specify comments, strings, etc within a tmLanguage file, which partially goes against the purpose of semantic tokens. Ideally VSCode should accept something (perhaps a token modifier) which would let us instruct it to disable bracket colorization within the token.

hediet commented 2 years ago

Hey @arcanis!

We intentionally don't allow semantic tokens to influence bracket matching. Bracket matching influences typing (e.g. when a closing bracket is inserted automatically) and semantic tokens are provided asynchronously. However, we don't want typing to depend on anything that cannot be provided/computed synchronously (such as semantic tokens) to prevent race-conditions.

However, we could implement a mechanism to just not highlight brackets in certain semantic tokens.

arcanis commented 2 years ago

I see, that makes a lot of sense - being able to at least disable highlighting on identified tokens would be a nice option workaround!