You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/injections.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ The injection syntax is parsed into the following tokens
34
34
35
35
*`L:` - `left` side priority selector `-1` to following the scopeName
36
36
*`R:` - `right` side priority selector `1` to following the scopeName
37
+
*`B:` - Both `left` and `right` side priority selectors (Github and [TextMate](https://github.com/textmate/textmate/blob/master/Frameworks/scope/src/types.h#L74) only. VSCode doesn't support it)
37
38
*__*__`:` - any char followed by `:` colon. Defaults to priority `0` to following the scopeName
38
39
*`(` - Open bracket group
39
40
*`)` - Close bracket group
@@ -91,3 +92,50 @@ You will need put the injections inside the parent grammar.
91
92
92
93
TextMate will inject the rules into the entire document.
93
94
Including recursively into the injected rules.
95
+
96
+
### Warning
97
+
TextMate 2.0 and Github have a bug where a injected `include` won't be applied if the `include` is already present in the same instance.
98
+
Causing `L:` to effectively be ignored.
99
+
100
+
For example in this grammar:
101
+
```json textmate
102
+
{
103
+
"scopeName": "source.languageId",
104
+
"injections": {
105
+
"L:source.languageId": {
106
+
"patterns": [ { "include": "#any" } ]
107
+
}
108
+
},
109
+
"patterns": [
110
+
{ "include": "#abc" },
111
+
{ "include": "#any" }
112
+
],
113
+
"repository": {
114
+
"abc": {
115
+
"match": "abc",
116
+
"name": "string.abc"
117
+
},
118
+
"any": {
119
+
"match": ".",
120
+
"name": "comment.any"
121
+
},
122
+
"any2": {
123
+
"match": ".",
124
+
"name": "comment.any"
125
+
}
126
+
}
127
+
}
128
+
```
129
+
It would be expected that this grammar matches the text `abc` with `comment.any`.
130
+
But instead it is matched with `string.abc`.
131
+
Even tho the injection has high priority `L:`.
132
+
TextMate and Github see that `#any` was already included from within the root level `patterns`.
133
+
Then proceeding to simply ignore it.
134
+
Forgetting that the order/priority of the `include` needs to be changed.
135
+
136
+
As you will see changing one of the `#any` to `#any2` fixes it.
137
+
Also removing `#any` from the root level `patterns` fixes it.
138
+
139
+
VSCode handles this correctly by not ignoring the duplicate injection `include`.
0 commit comments