mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 15:35:20 +01:00
Search provider - give different cacheKeys for different folders
This commit is contained in:
@@ -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'),
|
||||
// ];
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
// 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 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:', () => {
|
||||
|
||||
Reference in New Issue
Block a user