diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 51f8b8f5e5d..7cbea7b4289 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -90,6 +90,11 @@ declare module 'vscode' { isWordMatch?: boolean; } + export interface TextSearchOptions { + includes: GlobPattern[]; + excludes: GlobPattern[]; + } + export interface TextSearchResult { uri: Uri; range: Range; @@ -147,7 +152,7 @@ declare module 'vscode' { // find files by names // todo@joh, move into its own provider findFiles?(query: string, progress: Progress, token: CancellationToken): Thenable; - provideTextSearchResults?(query: TextSearchQuery, include: GlobPattern, exclude: GlobPattern, progress: Progress, token: CancellationToken): Thenable; + provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress, token: CancellationToken): Thenable; } export namespace workspace { diff --git a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts index c2dc6e8aa81..7778851490a 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts @@ -16,6 +16,7 @@ import { ISearchResultProvider, ISearchQuery, ISearchComplete, ISearchProgressIt import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; import { onUnexpectedError } from 'vs/base/common/errors'; import { values } from 'vs/base/common/map'; +import { isFalsyOrEmpty } from 'vs/base/common/arrays'; @extHostNamedCustomer(MainContext.MainThreadFileSystem) export class MainThreadFileSystem implements MainThreadFileSystemShape { @@ -103,12 +104,12 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv constructor( fileService: IFileService, searchService: ISearchService, - scheme: string, + private readonly _scheme: string, private readonly _handle: number, private readonly _proxy: ExtHostFileSystemShape ) { this._registrations = [ - fileService.registerProvider(scheme, this), + fileService.registerProvider(_scheme, this), searchService.registerSearchResultProvider(this), ]; } @@ -170,6 +171,20 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv search(query: ISearchQuery): PPromise { + if (isFalsyOrEmpty(query.folderQueries)) { + return PPromise.as(undefined); + } + + let includes = { ...query.includePattern }; + let excludes = { ...query.excludePattern }; + + for (const folderQuery of query.folderQueries) { + if (folderQuery.folder.scheme === this._scheme) { + includes = { ...includes, ...folderQuery.includePattern }; + excludes = { ...excludes, ...folderQuery.excludePattern }; + } + } + return new PPromise((resolve, reject, report) => { const search = new SearchOperation(report); @@ -177,7 +192,7 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv const promise = query.type === QueryType.File ? this._proxy.$findFiles(this._handle, search.id, query.filePattern) - : this._proxy.$provideTextSearchResults(this._handle, search.id, query.contentPattern, undefined, undefined); + : this._proxy.$provideTextSearchResults(this._handle, search.id, query.contentPattern, { excludes: Object.keys(excludes), includes: Object.keys(includes) }); promise.then(() => { this._searches.delete(search.id); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index a08706a7e6b..ea9d6e8b960 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -549,7 +549,7 @@ export interface ExtHostFileSystemShape { $readdir(handle: number, resource: UriComponents): TPromise<[UriComponents, IStat][]>; $rmdir(handle: number, resource: UriComponents): TPromise; $findFiles(handle: number, session: number, query: string): TPromise; - $provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, include: string, exclude: string): TPromise; + $provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, options: { includes: string[], excludes: string[] }): TPromise; } export interface ExtHostExtensionServiceShape { diff --git a/src/vs/workbench/api/node/extHostFileSystem.ts b/src/vs/workbench/api/node/extHostFileSystem.ts index 62dbf9b67fe..7a8b780fcc4 100644 --- a/src/vs/workbench/api/node/extHostFileSystem.ts +++ b/src/vs/workbench/api/node/extHostFileSystem.ts @@ -137,7 +137,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { }; return asWinJsPromise(token => provider.findFiles(query, progress, token)); } - $provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, include: string, exclude: string): TPromise { + $provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, options: { includes: string[], excludes: string[] }): TPromise { const provider = this._provider.get(handle); if (!provider.provideTextSearchResults) { return TPromise.as(undefined); @@ -151,6 +151,6 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { }]); } }; - return asWinJsPromise(token => provider.provideTextSearchResults(pattern, include, exclude, progress, token)); + return asWinJsPromise(token => provider.provideTextSearchResults(pattern, options, progress, token)); } }