@@ -53,7 +53,7 @@ class FileSearchEngine {
53
53
54
54
private globalExcludePattern ?: glob . ParsedExpression ;
55
55
56
- constructor ( private config : IFileQuery , private provider : FileSearchProviderNew , private sessionToken ?: CancellationToken ) {
56
+ constructor ( private config : IFileQuery , private provider : FileSearchProviderNew , private sessionToken ?: unknown ) {
57
57
this . filePattern = config . filePattern ;
58
58
this . includePattern = config . includePattern && glob . parse ( config . includePattern ) ;
59
59
this . maxResults = config . maxResults || undefined ;
@@ -305,11 +305,11 @@ export class FileSearchManager {
305
305
306
306
private static readonly BATCH_SIZE = 512 ;
307
307
308
- private readonly sessions = new Map < string , CancellationTokenSource > ( ) ;
308
+ private readonly sessions = new Map < string , unknown > ( ) ;
309
309
310
310
fileSearch ( config : IFileQuery , provider : FileSearchProviderNew , onBatch : ( matches : IFileMatch [ ] ) => void , token : CancellationToken ) : Promise < ISearchCompleteStats > {
311
311
const sessionTokenSource = this . getSessionTokenSource ( config . cacheKey ) ;
312
- const engine = new FileSearchEngine ( config , provider , sessionTokenSource && sessionTokenSource . token ) ;
312
+ const engine = new FileSearchEngine ( config , provider , sessionTokenSource ) ;
313
313
314
314
let resultCount = 0 ;
315
315
const onInternalResult = ( batch : IInternalFileMatch [ ] ) => {
@@ -333,17 +333,17 @@ export class FileSearchManager {
333
333
}
334
334
335
335
clearCache ( cacheKey : string ) : void {
336
- const sessionTokenSource = this . getSessionTokenSource ( cacheKey ) ;
337
- sessionTokenSource ?. cancel ( ) ;
336
+ // with no reference to this, it will be removed from WeakMaps
337
+ this . sessions . delete ( cacheKey ) ;
338
338
}
339
339
340
- private getSessionTokenSource ( cacheKey : string | undefined ) : CancellationTokenSource | undefined {
340
+ private getSessionTokenSource ( cacheKey : string | undefined ) : unknown {
341
341
if ( ! cacheKey ) {
342
342
return undefined ;
343
343
}
344
344
345
345
if ( ! this . sessions . has ( cacheKey ) ) {
346
- this . sessions . set ( cacheKey , new CancellationTokenSource ( ) ) ;
346
+ this . sessions . set ( cacheKey , new Object ( ) ) ;
347
347
}
348
348
349
349
return this . sessions . get ( cacheKey ) ;
0 commit comments