Skip to content
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

API to represent dead / inactive code #123352

Open
Trass3r opened this issue May 8, 2021 · 3 comments
Open

API to represent dead / inactive code #123352

Trass3r opened this issue May 8, 2021 · 3 comments
Labels
api editor-api Issues about the API of vscode in the area of editors feature-request Request for new features or functionality
Milestone

Comments

@Trass3r
Copy link

Trass3r commented May 8, 2021

Language plugins have to resort to custom LSP extensions to achieve a dimming effect for inactive code like in other IDEs:

1d8889f6e2913db87750cccfcf208441

I'd suggest adding an inactive or disabled SemanticTokenModifier and using it to style the code like in the picture.

The only question is how to make sure the whole line appears differently (iff the whole line is affected) and not just the portion of each inactive line covered by text, which may look weird.

@dbaeumer
Copy link
Member

@alexdima I assign this for you for now. We had this discussion a while back ago and we purposely decided to not have this in semantic tokens because they are restraint to a work/token. The idea was that we have a separate request to compute these fade effects. Is this still the way to go from your point of view?

@alexdima
Copy link
Member

alexdima commented Jun 7, 2021

👍 This has come up before, in this exact context of #ifdef pragmas, but also in the context of dead code (e.g. code after a return statement, code inside an if (false) {} block, etc.). We also thought that there might be more useful things to do with such inactive code regions than just render the text faded out, e.g. we could add options to fold these regions by default, to render the lines with a different brackground, etc.

I think we agreed that this does not fall under semantic tokens because such dead or inactive code could in certain cases get parsed by the compiler and could have semantic tokens independent of the fact that it is dead. I think we decided the best way forward is to add new special API in the future and until such new API is done to direct folks toward text editor decorations.

also cc @aeschli

@alexdima alexdima changed the title style inactive code API to represent dead / inactive code Jun 7, 2021
@alexdima alexdima added the feature-request Request for new features or functionality label Jun 7, 2021
@alexdima alexdima added this to the Backlog milestone Jun 7, 2021
@alexdima alexdima added editor-api Issues about the API of vscode in the area of editors and removed editor labels Oct 15, 2021
@alexdima alexdima removed their assignment Oct 15, 2021
@jrieken
Copy link
Member

jrieken commented Dec 7, 2022

Outside of semantic highlight you can use DiagnosticTag.Unnecessary. The name is slightly misleading but the only thing it does is that it dims the code marked like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api editor-api Issues about the API of vscode in the area of editors feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants