From e69e4d3a477de5acd64802ac355ad6563a248ed6 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 1 Aug 2018 10:04:20 -0700 Subject: [PATCH] Search provider - Fix FileSearchProvider to return array, not progress --- src/vs/vscode.proposed.d.ts | 2 +- src/vs/workbench/api/node/extHostSearch.ts | 39 +++++++++++----------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 8d6261752bb..93e24c066bf 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -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, token: CancellationToken): Thenable; + provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): Thenable; } /** diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index a4be83baa25..234132adf2b 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -488,24 +488,6 @@ class FileSearchEngine { const queryTester = new QueryGlobTester(this.config, fq); const noSiblingsClauses = !queryTester.hasSiblingExcludeClauses(); - const onProviderResult = (result: URI) => { - if (this.isCanceled) { - return; - } - - const relativePath = path.relative(fq.folder.fsPath, result.fsPath); - - if (noSiblingsClauses) { - const basename = path.basename(result.fsPath); - this.matchFile(onResult, { base: fq.folder, relativePath, basename }); - - return; - } - - // 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); @@ -515,10 +497,27 @@ class FileSearchEngine { pattern: this.config.filePattern || '' }, options, - { report: onProviderResult }, cancellation.token); }) - .then(() => { + .then(results => { + if (this.isCanceled) { + return; + } + + results.forEach(result => { + const relativePath = path.relative(fq.folder.fsPath, result.fsPath); + + if (noSiblingsClauses) { + const basename = path.basename(result.fsPath); + this.matchFile(onResult, { base: fq.folder, relativePath, basename }); + + return; + } + + // TODO: Optimize siblings clauses with ripgrep here. + this.addDirectoryEntries(tree, fq.folder, relativePath, onResult); + }); + this.activeCancellationTokens.delete(cancellation); if (this.isCanceled) { return null;