Vscode: tokenColorCustomizations priorities are wrong (or very confusing)

Created on 10 Feb 2020  路  9Comments  路  Source: microsoft/vscode



In the settings editor.tokenColorCustomizations.textMateRules, the scope "variable" has more priority than the (in my opinion) more specific scope "entitiy.name.function". This means that I can't manually assign a color to function names without overwriting the whole variable scope when my theme has set a color set for the variable scope.

  • VSCode Version: 1.42.0
  • OS Version: Windows_NT x64 6.1.7601

Steps to Reproduce:

  1. Add the following to settings.json:
"editor.tokenColorCustomizations": {
      "textMateRules": [
          {"scope": ["entity.name.function"],
          "settings": {
              "foreground": "#61AFEF",
          }},
          {"scope": ["variable"],
          "settings": {
              "foreground": "#FF0000",
          }},
      ]
},
  1. Observe how the entity.name.function gets overridden by the variable scope:
    screenshot with a function colored in bright red instead of blue


This issue occurs when all extensions are disabled.
I get no errors or warnings.

needs more info semantic-tokens typescript

Most helpful comment

In the insiders, functions are highlighted correctly now, thanks for that!

I follow your reasoning that semantic classification knows more than TextMate and should overrule it, but sometimes TextMate is more precise / fine tunable. For example, I think this issue still exists with for example console. TextMate knows console is special (it has support.class or even support.class.console for who wants it), but for semantic classification it's just a variable like the variable pat above it in the screenshot:
image

All 9 comments

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

I just noticed, when I open the window and the program is not done loading, during a short moment I get the correct syntax coloring:
screenshot with correct coloring
But then something finishes loading and the variable scope takes over again:
screenshot with wrong coloring

Notice how the yellow color of this survives, as it has the more specific variable.language, but console does not, as it is in support.class which also gets dominated by variable.

t's the semantic highlighting kicking in.
There was an issue that I fixed that variables that have a callable type should be rendered functions.
That is in the latest insiders. Did taht fix your issue?

If no, can you paste a code example? Or let me know what the hover over getDirectories shows.

I am experiencing the same issue. For example the only way to set color for key in js object literal is to use variable, variable.other or variable.other.property. Those rules override everything else.
image
Which is highly undesirable.

Yes the semantic classification overrules the TextMate grammar. That's the idea (as the language server knows more about the symbols).
Your example is not really related to the one of this issue. Can you create a new issue and describe what you want to have. You don't like that object keys are the same as properties?

Your example is not really related to the one of this issue. Can you create a new issue and describe what you want to have. You don't like that object keys are the same as properties?

Yes, exactly. Thank you for explanation, I will create a separate issue.

In the insiders, functions are highlighted correctly now, thanks for that!

I follow your reasoning that semantic classification knows more than TextMate and should overrule it, but sometimes TextMate is more precise / fine tunable. For example, I think this issue still exists with for example console. TextMate knows console is special (it has support.class or even support.class.console for who wants it), but for semantic classification it's just a variable like the variable pat above it in the screenshot:
image

Yes, the semantic highlight has no understanding of 'built-in' types.
If you want to file an feature request...

I created https://github.com/microsoft/vscode/issues/91090 for supporting different rendering of the 'standard' types and variables.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lw-schick picture lw-schick  路  229Comments

Perkovec picture Perkovec  路  191Comments

Brakkar picture Brakkar  路  364Comments

filfat picture filfat  路  246Comments

niagr picture niagr  路  246Comments