File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,17 @@ import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-text
2
2
3
3
const target = vscodeTextmate as typeof vscodeTextmate ;
4
4
5
+ const ctx = ( require as any ) . context ( "../../../../lib/extensions" , true , / .* \. t m L a n g u a g e .j s o n $ / ) ;
6
+ // Maps grammar scope to loaded grammar
7
+ const scopeToGrammar = { } as any ;
8
+
9
+ ctx . keys ( ) . forEach ( ( key : string ) => {
10
+ const value = ctx ( key ) ;
11
+ if ( value . scopeName ) {
12
+ scopeToGrammar [ value . scopeName ] = value ;
13
+ }
14
+ } ) ;
15
+
5
16
target . Registry = class Registry extends vscodeTextmate . Registry {
6
17
public constructor ( opts : vscodeTextmate . RegistryOptions ) {
7
18
super ( {
@@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
21
32
} ) . catch ( reason => rej ( reason ) ) ;
22
33
} ) ;
23
34
} ,
35
+ loadGrammar : async ( scopeName : string ) => {
36
+ if ( scopeToGrammar [ scopeName ] ) {
37
+ return scopeToGrammar [ scopeName ] ;
38
+ }
39
+
40
+ return opts . loadGrammar ( scopeName ) ;
41
+ } ,
24
42
} ) ;
25
43
}
26
44
} ;
You can’t perform that action at this time.
0 commit comments