Skip to content

Commit

Permalink
Search provider - Fix FileSearchProvider to return array, not progress
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Aug 1, 2018
1 parent d70dd23 commit e69e4d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]>;
}

/**
Expand Down
39 changes: 19 additions & 20 deletions src/vs/workbench/api/node/extHostSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit e69e4d3

Please sign in to comment.