question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextMate scope selectors: scope exclusion is not implemented

See original GitHub issue

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 with entity.name.method but not if a parent scope matches source.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:

  1. 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"
                }
            }
        ]
    }
}
  1. 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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:29
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
jaymegordocommented, Oct 7, 2020

+1 for exclusions please!

5reactions
curiouslychasecommented, Sep 26, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scope Selectors — TextMate 1.x Manual
A scope selector is a pattern much like a CSS selector which is matched against the scope of the caret (i.e. current context)...
Read more >
Sublime Text: scope selector operators
Excluding Elements "we can subtract scope selectors to get the (asymmetric) difference using the minus operator." · Comma "When we want something ...
Read more >
Scope Naming
The TextMate language grammar documentation provided a base set of scope names that have been slowly expanded and changed by the community.
Read more >
Syntax Definitions - Sublime Text Unofficial Documentation
Sublime Text inherits the idea of scopes from Textmate, a text editor for Mac. Textmate's online manual contains further information about scope selectors...
Read more >
TextMate User Manual
Currently it is not possible to limit the scope of the search to anything other than all text files in the full project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found