File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 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
22
33const target = vscodeTextmate as typeof vscodeTextmate ;
44
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+
516target . Registry = class Registry extends vscodeTextmate . Registry {
617 public constructor ( opts : vscodeTextmate . RegistryOptions ) {
718 super ( {
@@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
2132 } ) . catch ( reason => rej ( reason ) ) ;
2233 } ) ;
2334 } ,
35+ loadGrammar : async ( scopeName : string ) => {
36+ if ( scopeToGrammar [ scopeName ] ) {
37+ return scopeToGrammar [ scopeName ] ;
38+ }
39+
40+ return opts . loadGrammar ( scopeName ) ;
41+ } ,
2442 } ) ;
2543 }
2644} ;
You can’t perform that action at this time.
0 commit comments