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

Semantic Tokens for TypeScript Template Literal Strings #58900

Open
benrbray opened this issue Jun 11, 2024 · 1 comment
Open

Semantic Tokens for TypeScript Template Literal Strings #58900

benrbray opened this issue Jun 11, 2024 · 1 comment
Labels
Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@benrbray
Copy link

(moved from typescript-language-server/typescript-language-server#901)

Problem

In VS Code, semantic token theme colors override textmate token colors (even when they are user defined). This usually makes sense, as the semantic tokens are intended to provide more specific information about tokens than what is available from syntax alone.

However, based on the output of VS Code's Developer: Inspect Editor Tokens and Scopes command, it appears that typescript-language-server labels all template strings with the generic string scope. As a result, template strings will not receive syntax highlighting when semantic tokens are enabled, degrading the user experience writing TypeScript when semantic highlighting is enabled.

As you can see from the image below, the textmate grammar knows that animal is a variable inside of a template string, but the semantic token string is taking precedence.

help

Possible Solutions

  • The best would be to add more granular semantic tokens for template literal strings.
  • Another possible solution would to allow more fine-grained control over the interaction between semantic highlighting and textmate highlighting. At the moment, semantic highlights always get priority.

Related Issues

@alexdima alexdima assigned mjbvz and unassigned alexdima Jun 12, 2024
@mjbvz mjbvz transferred this issue from microsoft/vscode Jun 17, 2024
@mjbvz mjbvz removed their assignment Jun 17, 2024
@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels Jun 17, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 17, 2024
@benrbray
Copy link
Author

benrbray commented Jun 18, 2024

I've also noticed that the following keywords are not given their own semantic token type (instead, they are treated as variable) only:

  • null
  • true
  • false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Projects
None yet
Development

No branches or pull requests

4 participants