VS Code配置editor.tokenColorCustomizations时设置string属性提示“Property string is not allowed”错误求助
Hey there! Let's break down why you're seeing that error and how to fix it.
Why the Error Happens
The Property string is not allowed message pops up because the Tinacious Design (legacy, 2016) theme you're using is an older one that doesn't support the simplified top-level string property in editor.tokenColorCustomizations. While some modern themes map these simplified properties (like comments, which worked for you) to their internal token structures, this legacy theme doesn't include that mapping for strings. VS Code's configuration validator picks up on this mismatch and throws the error.
How to Fix It
Instead of using the simplified string property, you'll need to use VS Code's textMateRules to target the exact text mate scope for strings. This approach works across all themes, including older ones.
Here's the updated configuration for your settings.json:
"editor.tokenColorCustomizations": { "[Tinacious Design (legacy, 2016)]": { "comments": "#797979", "textMateRules": [ { "scope": "string", "settings": { "foreground": "#898989" } } ] } }
Extra Tip: Verify the Exact Scope
If the string color still doesn't update as expected, you can confirm the precise text mate scope for strings in your theme:
- Open the command palette (Ctrl+Shift+P on Windows/Linux, Cmd+Shift+P on Mac)
- Search for and run Developer: Inspect Editor Tokens and Scopes
- Click on any string in your editor to see its associated scope(s). Use the most relevant scope in the
scopefield of yourtextMateRulesentry.
Once you save the updated settings.json, the error should disappear, and your string color will be applied correctly.
内容的提问来源于stack exchange,提问作者ImBatman

