Closed captbaritone closed 6 years ago
My apologies, I believe that is a bug. My forum question was answered by @50Wliu, and I got the impression it was a property designed to inject the current grammar into another when the other gained the specified scope. For example, the ideal use case in a Markdown file is when the user types
```js
Using `injectionSelector`, the code within the code block will get proper syntax highlighting. I got no impression it was solely for grammars for scopes.
However, there is a workaround that has the same effect as the embedding, but without this bug. Making a new grammar file (e.g., called `embeddedBabel.json`) and filling it out like so:
```json
{
"scopeName": "source.embedded.js.jsx",
"injectionSelector": "source.embedded.jsx",
"patterns": [{ "include": "source.js.jsx" }]
}
Turns the injecting part into a standalone grammar, which prevents the glitch.
FYI, I also have another forum post where I go through all the valid properties I could find.
If you (re)start Atom with some JS files already open,
Babel ES6 JavaScript
does not get applied.Regressed here: https://github.com/gandm/language-babel/pull/473
Since packages (and thus grammars) are loaded async, when a new grammar is added, Atom checks all open files to see if the new grammar should trump the one it currently has.
https://github.com/atom/atom/blob/1dc700182171ae2fe8773bed703a62104aad0b8e/src/grammar-registry.js#L330
The addition of
injectionSelector
seems to cause this process to short circuit. I can't seem to find much documentation for howinjectionSelector
is supposed to be used, but I it looks to me (based on the Atom code and this discussion) like it's only intended for grammars that apply to scopes, not entire files.CC @wbinnssmith @Aerijo @gandm