Skip to content

Commit 652478d

Browse files
authored
make session for fileSearchProvider just an empty object (microsoft#226687)
make session for fileSearchProvider just an unknown
1 parent 79f1a95 commit 652478d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/vs/workbench/services/search/common/fileSearchManager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FileSearchEngine {
5353

5454
private globalExcludePattern?: glob.ParsedExpression;
5555

56-
constructor(private config: IFileQuery, private provider: FileSearchProviderNew, private sessionToken?: CancellationToken) {
56+
constructor(private config: IFileQuery, private provider: FileSearchProviderNew, private sessionToken?: unknown) {
5757
this.filePattern = config.filePattern;
5858
this.includePattern = config.includePattern && glob.parse(config.includePattern);
5959
this.maxResults = config.maxResults || undefined;
@@ -305,11 +305,11 @@ export class FileSearchManager {
305305

306306
private static readonly BATCH_SIZE = 512;
307307

308-
private readonly sessions = new Map<string, CancellationTokenSource>();
308+
private readonly sessions = new Map<string, unknown>();
309309

310310
fileSearch(config: IFileQuery, provider: FileSearchProviderNew, onBatch: (matches: IFileMatch[]) => void, token: CancellationToken): Promise<ISearchCompleteStats> {
311311
const sessionTokenSource = this.getSessionTokenSource(config.cacheKey);
312-
const engine = new FileSearchEngine(config, provider, sessionTokenSource && sessionTokenSource.token);
312+
const engine = new FileSearchEngine(config, provider, sessionTokenSource);
313313

314314
let resultCount = 0;
315315
const onInternalResult = (batch: IInternalFileMatch[]) => {
@@ -333,17 +333,17 @@ export class FileSearchManager {
333333
}
334334

335335
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);
338338
}
339339

340-
private getSessionTokenSource(cacheKey: string | undefined): CancellationTokenSource | undefined {
340+
private getSessionTokenSource(cacheKey: string | undefined): unknown {
341341
if (!cacheKey) {
342342
return undefined;
343343
}
344344

345345
if (!this.sessions.has(cacheKey)) {
346-
this.sessions.set(cacheKey, new CancellationTokenSource());
346+
this.sessions.set(cacheKey, new Object());
347347
}
348348

349349
return this.sessions.get(cacheKey);

0 commit comments

Comments
 (0)