Search provider - Fix FileSearchProvider to return array, not progress

This commit is contained in:
Rob Lourens 2018-08-01 10:04:20 -07:00
parent d70dd23466
commit e69e4d3a47
2 changed files with 20 additions and 21 deletions

View file

@ -192,7 +192,7 @@ declare module 'vscode' {
* @param progress A progress callback that must be invoked for all results.
* @param token A cancellation token.
*/
provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): Thenable<Uri[]>;
}
/**

View file

@ -488,11 +488,23 @@ class FileSearchEngine {
const queryTester = new QueryGlobTester(this.config, fq);
const noSiblingsClauses = !queryTester.hasSiblingExcludeClauses();
const onProviderResult = (result: URI) => {
new TPromise(_resolve => process.nextTick(_resolve))
.then(() => {
this.activeCancellationTokens.add(cancellation);
return this.provider.provideFileSearchResults(
{
pattern: this.config.filePattern || ''
},
options,
cancellation.token);
})
.then(results => {
if (this.isCanceled) {
return;
}
results.forEach(result => {
const relativePath = path.relative(fq.folder.fsPath, result.fsPath);
if (noSiblingsClauses) {
@ -504,21 +516,8 @@ class FileSearchEngine {
// TODO: Optimize siblings clauses with ripgrep here.
this.addDirectoryEntries(tree, fq.folder, relativePath, onResult);
};
});
new TPromise(_resolve => process.nextTick(_resolve))
.then(() => {
this.activeCancellationTokens.add(cancellation);
return this.provider.provideFileSearchResults(
{
pattern: this.config.filePattern || ''
},
options,
{ report: onProviderResult },
cancellation.token);
})
.then(() => {
this.activeCancellationTokens.delete(cancellation);
if (this.isCanceled) {
return null;