diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 5e103f86870..6c54d1f4f9f 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -2189,11 +2189,16 @@ export enum ConfigurationTarget { @es5ClassCompat export class RelativePattern implements IRelativePattern { base: string; - baseFolder?: URI; - pattern: string; - constructor(base: URI | vscode.WorkspaceFolder | string, pattern: string) { + // expose a `baseFolder: URI` property as a workaround for the short-coming + // of `IRelativePattern` only supporting `base: string` which always translates + // to a `file://` URI. With `baseFolder` we can support non-file based folders + // in searches + // (https://github.com/microsoft/vscode/commit/6326543b11cf4998c8fd1564cab5c429a2416db3) + readonly baseFolder?: URI; + + constructor(base: vscode.WorkspaceFolder | URI | string, pattern: string) { if (typeof base !== 'string') { if (!base || !URI.isUri(base) && !URI.isUri(base.uri)) { throw illegalArgument('base'); @@ -2205,6 +2210,7 @@ export class RelativePattern implements IRelativePattern { } if (typeof base === 'string') { + this.baseFolder = URI.file(base); this.base = base; } else if (URI.isUri(base)) { this.baseFolder = base; diff --git a/src/vs/workbench/api/common/extHostWorkspace.ts b/src/vs/workbench/api/common/extHostWorkspace.ts index 1434932e36e..3e0de07e3f4 100644 --- a/src/vs/workbench/api/common/extHostWorkspace.ts +++ b/src/vs/workbench/api/common/extHostWorkspace.ts @@ -467,17 +467,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac } : options.previewOptions; - let includePattern: string | undefined; - let folder: URI | undefined; - if (options.include) { - if (typeof options.include === 'string') { - includePattern = options.include; - } else { - includePattern = options.include.pattern; - folder = (options.include as RelativePattern).baseFolder || URI.file(options.include.base); - } - } - + const { includePattern, folder } = parseSearchInclude(options.include); const excludePattern = (typeof options.exclude === 'string') ? options.exclude : options.exclude ? options.exclude.pattern : undefined; const queryOptions: ITextQueryBuilderOptions = { @@ -572,14 +562,12 @@ function parseSearchInclude(include: RelativePattern | string | undefined): { in includePattern = include; } else { includePattern = include.pattern; - - // include.base must be an absolute path includeFolder = include.baseFolder || URI.file(include.base); } } return { - includePattern: includePattern, + includePattern, folder: includeFolder }; }