vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

[Feature Request] Semantic highlight of each local variable with a different color

Open krupitskas opened this issue 3 years ago • 6 comments

Feature Request

Hello!

I really like enhanced highlighting, but I've saw feature called semantic highlighting in the CLion which is basically highlights all the local variables with a different color, which makes it easier to distinguish. I'm curios, is it possible to do it with intellisense? If it is, maybe you can guide me a bit and I would glad to contribute. As example I attach my project, as you can see, 3 variables initialized and all of them has different color. Thanks! image

krupitskas avatar Jun 06 '22 21:06 krupitskas

I don't believe this can be implemented without additional support from VS Code: https://github.com/microsoft/vscode/issues

@Colengms correct me me if I'm mistaken.

sean-mcmanus avatar Jun 06 '22 22:06 sean-mcmanus

highlights all the local variables with a different color

Hi @krupitskas . The C/C++ extension does return a distinct token for local variables. You can see how tokens (both syntactic tokens from VS Code and semantic tokens from the C/C++ extension) are associated with your code using the Developer: Inspect Editor Tokens and Scopes command, then clicking on a keyword in your source code.

image

If the theme you are using does not use a unique color for a token that you would like colored uniquely, you can override the colorization of that token in your local settings. Guidance on this is here and here

Colengms avatar Jun 06 '22 22:06 Colengms

@Colengms Yeah, I was right about to add that scope info you provided. However, they're requesting a feature from VS Code that auto-rotates the color, similar to what VS Code does with braces.

The specific data we provide VS Code is image which VS Code would need to check to decide if colors should be rotated in that case (not sure if themes should opt-in to that color rotation and/or if there should be a user setting to override the theme colors).

sean-mcmanus avatar Jun 06 '22 22:06 sean-mcmanus

Indeed, the auto-rotating of the color would require support from VS Code. @krupitskas , consider opening a feature request against VS Code for this.

Colengms avatar Jun 06 '22 22:06 Colengms

similar to what VS Code does with braces.

Actually this is interesting, because this was a separate extension which did it. Now it's achieved, because VS code has integrated it, but still, I can take a look how brace color rotatation was implemented.

krupitskas avatar Jun 08 '22 12:06 krupitskas

We could potentially implement this in the C/C++ extension using editor 'text decorations'. However, that's very inefficient. If instead VS Code were to handle the coloration for us and provide an API to allow us to group tokens for the same variable, that could potentially provide much better performance.

Colengms avatar Jul 27 '22 01:07 Colengms

This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.

github-actions[bot] avatar Sep 25 '22 11:09 github-actions[bot]

This feature request has received enough votes to be added to our backlog.

github-actions[bot] avatar Jan 14 '23 12:01 github-actions[bot]