@@ -28,6 +28,7 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
2828
2929 readonly start = new Position ( 0 , 0 ) ;
3030 readonly cache = new Map < string , CompletionItem [ ] > ( ) ;
31+ readonly files = new Map < string , string > ( ) ;
3132 readonly watchers = new Map < string , Disposable > ( ) ;
3233 readonly isRemote = / ^ h t t p s ? : \/ \/ / i;
3334 readonly canComplete = / ( i d | c l a s s | c l a s s N a m e ) \s * = \s * ( " | ' ) (?: (? ! \2) .) * $ / si;
@@ -39,6 +40,7 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
3940 this . watchers . forEach ( e => e . dispose ( ) ) ;
4041 this . watchers . clear ( ) ;
4142 this . cache . clear ( ) ;
43+ this . files . clear ( ) ;
4244 }
4345
4446 watchFile ( path : string , listener : ( e : Uri ) => any ) {
@@ -187,11 +189,17 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
187189
188190 const name = extended [ 2 ] ;
189191 const ext = extname ( name ) || extname ( uri . fsPath ) ;
190- const file = Uri . file ( this . getPath ( uri , name , ext ) ) ;
192+ const path = this . getPath ( uri , name , ext ) ;
193+ const file = Uri . file ( path ) ;
194+
195+ let text = this . files . get ( path ) ;
191196
192197 try {
193- const content = await workspace . fs . readFile ( file ) ;
194- const text = content . toString ( ) ;
198+ if ( ! text ) {
199+ text = ( await workspace . fs . readFile ( file ) ) . toString ( ) ;
200+ this . files . set ( path , text ) ;
201+ this . watchFile ( path , ( ) => this . files . delete ( path ) ) ;
202+ }
195203
196204 this . findEmbedded ( file , keys , text ) ;
197205
0 commit comments