From a54b448fd925315060a2eabe69c7f3da6d5901f0 Mon Sep 17 00:00:00 2001 From: Jared Moore Date: Thu, 30 Nov 2017 09:31:46 -0500 Subject: [PATCH] Tilde expansion for files to include and exclude (fixes #36792) --- src/vs/workbench/parts/search/common/queryBuilder.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/search/common/queryBuilder.ts b/src/vs/workbench/parts/search/common/queryBuilder.ts index 5c8e0d65015..5862685e220 100644 --- a/src/vs/workbench/parts/search/common/queryBuilder.ts +++ b/src/vs/workbench/parts/search/common/queryBuilder.ts @@ -12,9 +12,11 @@ import * as glob from 'vs/base/common/glob'; import * as paths from 'vs/base/common/paths'; import * as strings from 'vs/base/common/strings'; import uri from 'vs/base/common/uri'; +import { untildify } from 'vs/base/common/labels'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IPatternInfo, IQueryOptions, IFolderQuery, ISearchQuery, QueryType, ISearchConfiguration, getExcludes, pathIncludedInQuery } from 'vs/platform/search/common/search'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; export interface ISearchPathPattern { searchPath: uri; @@ -30,8 +32,9 @@ export class QueryBuilder { constructor( @IConfigurationService private configurationService: IConfigurationService, - @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService) { - } + @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, + @IEnvironmentService private environmentService: IEnvironmentService + ) { } public text(contentPattern: IPatternInfo, folderResources?: uri[], options?: IQueryOptions): ISearchQuery { return this.query(QueryType.Text, contentPattern, folderResources, options); @@ -105,7 +108,8 @@ export class QueryBuilder { return paths.isAbsolute(segment) || strings.startsWith(segment, './') || strings.startsWith(segment, '.\\'); }; - const segments = splitGlobPattern(pattern); + const segments = splitGlobPattern(pattern) + .map(segment => untildify(segment, this.environmentService.userHome)); const groups = collections.groupBy(segments, segment => isSearchPath(segment) ? 'searchPaths' : 'exprSegments'); -- GitLab