提交 21082bf9 编写于 作者: R Rob Lourens

Search provider - give different cacheKeys for different folders

上级 70211888
......@@ -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);
......
......@@ -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'),
// ];
// await registerTestSearchProvider({
// provideFileSearchResults(options: vscode.FileSearchOptions, progress: vscode.Progress<URI>, token: vscode.CancellationToken): Thenable<void> {
// reportedResults.forEach(r => progress.report(r));
// return TPromise.wrap(null);
// }
// });
// const queriedFilePath = queriedFile.fsPath;
// const { results } = await runFileSearch(getSimpleQuery(queriedFilePath));
// assert.equal(results.length, 1);
// compareURIs(results, [queriedFile]);
// });
test('uses different cache keys for different folders', async () => {
const cacheKeys: string[] = [];
await registerTestSearchProvider({
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, progress: vscode.Progress<URI>, token: vscode.CancellationToken): Thenable<void> {
cacheKeys.push(query.cacheKey);
return TPromise.wrap(null);
}
});
const query: ISearchQuery = {
type: QueryType.File,
filePattern: '',
cacheKey: 'cacheKey',
folderQueries: [
{
folder: rootFolderA
},
{
folder: rootFolderB
}
]
};
await runFileSearch(query);
assert.equal(cacheKeys.length, 2);
assert.notEqual(cacheKeys[0], cacheKeys[1]);
});
});
suite('Text:', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册