microsoft / vscode

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

[Bug] Semantic highlighting doesn't work after language mode switch #144096

Closed whaaaley closed 2 years ago

whaaaley commented 2 years ago

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

Version: 1.64.2 (user setup) Commit: f80445acd5a3dadef24aa209168452a3d97cc326 Date: 2022-02-09T22:02:28.252Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.22000

Steps to Reproduce:

  1. Open a file using a theme with ONLY semanticTokenColors so the effect is seen most clearly.
  2. Swap the highlighter from one to another.
  3. The file is just gray. No highlighting.
ArturoDent commented 2 years ago

What is the "highlighter" in the bottom right you are referring to? The Select Language Mode button?

And you should try to see if this an extension-related problem by reloading with all extensions disabled and see if the problem persists.

whaaaley commented 2 years ago

@ArturoDent Yes. That is the button. I do not have any extensions enabled. Only the built-in extensions. If this is a problem with a built-in extension where would I report that bug?

I found this bug while developing a theme. Semantic tokens are just not applied after swapping.

Tested swaps were between Javascript / Javascript React / Typescript. In any of these cases the textmate tokens are fine, but semantic tokens are not.

For example. Function parameters are often styled using semantic tokens to differentiate a regular variable from a parameter. Also, variables containing functions are often styled differently using semantic tokens.

aeschli commented 2 years ago

What does the Developer: Editor Tokens and Scopes hover show? Please add screenshots.

whaaaley commented 2 years ago

Before image

After swapping to Typescript and back image

My guess is that the LSP theme stuff that semantic tokens rely upon is never get re-initiated upon switching. Fwiw I did see another issue about LSP stuff lagging behind. That would explain the red squiggles being there when they're not supposed to be. However I'm not an expert here so I can't say if it's related or not.

aeschli commented 2 years ago

I can't reproduce with the semantic highlight sample. Also with most TS examples I tried, all was correctly rendered after switching back to TypeScript.

Can you provide a small project that shows the problem?

Does the TypeScript: Reload Project command solve the issue?

whaaaley commented 2 years ago

I might be able to provide a small theme. However, the Github Dark Dimmed Theme theme has this issue pretty clearly with parameters and variables. It looks like VSCode's default theme doesn't make use of different colored parameters.

gif

Reloading the project didn't seem to have any affect but editing the file seems to fix it. I didn't realize this at first because I was using a separate vscode window to do theme testing. I wasn't editing my test files for my themes.

vscodenpa commented 2 years ago

Hey @aeschli @mjbvz, this issue might need further attention.

@whaaaley, you can help us out by closing this issue if the problem no longer exists, or adding more information.

vscodenpa commented 2 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!