diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index aeba2749c5f..4f9c48ed0eb 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -621,7 +621,10 @@ class FileSearchEngine { .then(() => { this.activeCancellationTokens.add(cancellation); return this.provider.provideFileSearchResults( - { cacheKey: this.config.cacheKey, pattern: this.config.filePattern || '' }, + { + pattern: this.config.filePattern || '', + cacheKey: this.config.cacheKey + '_' + fq.folder.fsPath + }, options, { report: onProviderResult }, cancellation.token); diff --git a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts index 3c5cceb4ce7..49d33da63b2 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts @@ -666,27 +666,33 @@ suite('ExtHostSearch', () => { compareURIs(results, reportedResults); }); - // Mock fs? - // test('Returns result for absolute path', async () => { - // const queriedFile = makeFileResult(rootFolderA, 'file2.ts'); - // const reportedResults = [ - // makeFileResult(rootFolderA, 'file1.ts'), - // queriedFile, - // makeFileResult(rootFolderA, 'file3.ts'), - // ]; + test('uses different cache keys for different folders', async () => { + const cacheKeys: string[] = []; + await registerTestSearchProvider({ + provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Thenable { + cacheKeys.push(query.cacheKey); + return TPromise.wrap(null); + } + }); - // await registerTestSearchProvider({ - // provideFileSearchResults(options: vscode.FileSearchOptions, progress: vscode.Progress, token: vscode.CancellationToken): Thenable { - // reportedResults.forEach(r => progress.report(r)); - // return TPromise.wrap(null); - // } - // }); + const query: ISearchQuery = { + type: QueryType.File, + filePattern: '', + cacheKey: 'cacheKey', + folderQueries: [ + { + folder: rootFolderA + }, + { + folder: rootFolderB + } + ] + }; - // const queriedFilePath = queriedFile.fsPath; - // const { results } = await runFileSearch(getSimpleQuery(queriedFilePath)); - // assert.equal(results.length, 1); - // compareURIs(results, [queriedFile]); - // }); + await runFileSearch(query); + assert.equal(cacheKeys.length, 2); + assert.notEqual(cacheKeys[0], cacheKeys[1]); + }); }); suite('Text:', () => {