vscode-textmate: TextMate scope selectors: scope exclusion is not implemented
From @monk-time on September 4, 2017 14:51
- VSCode Version: Code 1.15.1 (41abd21afdf7424c89319ee7cb0445cc6f376959, 2017-08-16T18:07:25.676Z)
- OS Version: Windows_NT x64 6.1.7601
- Extensions:
Extension | Author (truncated) | Version |
---|---|---|
intellij-idea-keybindings | k– | 0.2.13 |
selectline-statusbar | tom | 0.0.2 |
Also the same result with today’s VS Code Insiders build.
According to the documentation for TextMate scope selectors, VSCode supports the syntax for excluding matching scopes:
entity.name.method - source.java
matches all scopes that start withentity.name.method
but not if a parent scope matchessource.java
This functionality is used in at least one built-in theme that I could find: https://github.com/Microsoft/vscode/blob/c00bdb74ee665cccfc5c4e41520893bb19ef61e5/extensions/theme-monokai/themes/monokai-color-theme.json#L316
But it seems that this syntax makes the selector with -
in it invalid, and VSCode doesn’t apply the given rule to anything at all.
Steps to Reproduce:
- Put this rule for syntax highlighting in the settings. Confirm that comments turn yellow at least in some files.
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "comment",
"settings": {
"foreground": "#FFFF00"
}
}
]
}
}
- Change the line with the scope selector to:
"scope": "comment - source.js",
Expected result: comments that changed their color after step 1 remain yellow in all files except in.js
. Actual result: all comments reset to a color defined by the current theme.
Reproduces without extensions: Yes
Copied from original issue: Microsoft/vscode#33802
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 30
- Comments: 18 (1 by maintainers)
Commits related to this issue
- Merge pull request #52 from DustinCampbell/issue-44 Add support for expression-bodied property and event accessors — committed to OmniSharp/vscode-textmate by DustinCampbell 7 years ago
+1 for exclusions please!
just to make sure it’s captured, the descendant scope selectors such as
"source.ts meta.import-equals.external.ts"
aren’t working either (mentioned from Microsoft/vscode#34909), so it seems like anything beyond a single selector isn’t being applied.Instead of WASM we can add caching logic to ScopeSelector class for match results, and this will work at 75% of the speed of the existing VS Code matchers! I will open a pull request for this soonish
As an example of the inconvenience not having descendant selectors causes, in my personal theme, instead of the scope
["keyword source.python", "punctuation source.python"]
, I’m using this quasi-exhaustive list, which I keep having to add to:[ "keyword.operator.arithmetic.python", "keyword.operator.assignment.python", "keyword.operator.comparison.python", "punctuation.definition.arguments.begin.python", "punctuation.definition.arguments.end.python", "punctuation.definition.dict.begin.python", "punctuation.definition.dict.end.python", "punctuation.definition.list.begin.python", "punctuation.definition.list.end.python", "punctuation.section.function.lambda.begin.python", "punctuation.separator.annotation.result.python", "punctuation.separator.arguments.python", "punctuation.separator.colon.python", "punctuation.separator.element.python", "punctuation.separator.period.python" ]