11import fetch from "node-fetch" ;
2- import { FSWatcher , watch } from "chokidar" ;
2+ import { watch } from "chokidar" ;
33import { parse , walk } from "css-tree" ;
44import {
55 CancellationToken ,
@@ -157,7 +157,7 @@ export class ClassCompletionItemProvider implements CompletionItemProvider {
157157 return items ;
158158 }
159159
160- buildItems ( items : Map < string , CompletionItem > , ... sets : Set < string > [ ] ) : CompletionItem [ ] {
160+ buildItems ( items : Map < string , CompletionItem > , sets : Set < string > [ ] ) : CompletionItem [ ] {
161161 const keys = new Set < string > ( ) ;
162162
163163 sets . forEach ( v => v . forEach ( v => keys . add ( v ) ) ) ;
@@ -187,7 +187,7 @@ export class ClassCompletionItemProvider implements CompletionItemProvider {
187187 this . findLocalStyles ( ) ,
188188 this . findDocumentLinks ( text ) ,
189189 this . findRemoteStyles ( document . uri ) ,
190- ] ) . then ( keys => resolve ( this . buildItems ( items , ... keys ) ) ) ;
190+ ] ) . then ( keys => resolve ( this . buildItems ( items , keys ) ) ) ;
191191 } else {
192192 reject ( ) ;
193193 }
@@ -196,8 +196,6 @@ export class ClassCompletionItemProvider implements CompletionItemProvider {
196196 }
197197}
198198
199- export let watcher : FSWatcher ;
200-
201199export function activate ( context : ExtensionContext ) {
202200 const provider = new ClassCompletionItemProvider ( ) ;
203201
@@ -212,12 +210,12 @@ export function activate(context: ExtensionContext) {
212210 const folders = workspace . workspaceFolders ?. map ( folder => `${ folder . uri . fsPath } /${ glob } ` ) ;
213211
214212 if ( folders ) {
215- watcher = watch ( folders , { ignored : [ "**/node_modules/**" , "**/test*/**" ] } )
213+ const watcher = watch ( folders , { ignored : [ "**/node_modules/**" , "**/test*/**" ] } )
216214 . on ( "add" , key => provider . files . add ( key ) )
217215 . on ( "unlink" , key => provider . files . delete ( key ) )
218216 . on ( "change" , key => provider . cache . delete ( key ) ) ;
219217
220- workspace . onDidChangeWorkspaceFolders ( e => {
218+ const changes = workspace . onDidChangeWorkspaceFolders ( e => {
221219 e . removed . forEach ( folder => {
222220 watcher . unwatch ( `${ folder . uri . fsPath } /${ glob } ` ) ;
223221
@@ -230,9 +228,9 @@ export function activate(context: ExtensionContext) {
230228
231229 e . added . forEach ( folder => watcher . add ( `${ folder . uri . fsPath } /${ glob } ` ) ) ;
232230 } ) ;
231+
232+ context . subscriptions . push ( changes , { dispose : ( ) => watcher . close ( ) } ) ;
233233 }
234234}
235235
236- export function deactivate ( ) {
237- return watcher ?. close ( ) ;
238- }
236+ export function deactivate ( ) { }
0 commit comments