diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 9efc4a7a891783524a9914296126da12d64fc3c2..e77014bfdacdad20b218baf735c15489b0039a29 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -864,7 +864,7 @@ export class SearchViewlet extends Viewlet { let folderPath = null; const workspace = this.contextService.getWorkspace(); if (workspace && resource) { - if (workspace.roots.length === 1) { + if (this.contextService.hasFolderWorkspace()) { // Show relative path from the root for single-root mode folderPath = paths.relative(workspace.roots[0].fsPath, resource.fsPath); if (folderPath && folderPath !== '.') { diff --git a/src/vs/workbench/parts/search/common/queryBuilder.ts b/src/vs/workbench/parts/search/common/queryBuilder.ts index bf7404c5c22c03af8061f9f0efa758ba558029ec..cbfc834974bc8c5272c42d87545c750934d1f8a7 100644 --- a/src/vs/workbench/parts/search/common/queryBuilder.ts +++ b/src/vs/workbench/parts/search/common/queryBuilder.ts @@ -206,11 +206,11 @@ export class QueryBuilder { } const workspace = this.workspaceContextService.getWorkspace(); - if (workspace.roots.length === 1) { + if (this.workspaceContextService.hasFolderWorkspace()) { return [paths.normalize( paths.join(workspace.roots[0].fsPath, searchPath))]; } else if (searchPath === './') { - return []; // ./ or ./**/foo makes sense for single-root but not multiroot + return []; // ./ or ./**/foo makes sense for single-folder but not multi-folder workspaces } else { const relativeSearchPathMatch = searchPath.match(/\.\/([^\/]+)(\/.+)?/); if (relativeSearchPathMatch) { diff --git a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts index b108cbde30c1a63b4c0e531953aea74ad7bc1e19..b80661f1d346e9ebc7159237051b2612df002a62 100644 --- a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts +++ b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts @@ -139,6 +139,7 @@ suite('QueryBuilder', () => { const ROOT_3 = fixPath('/project/root3'); const ROOT_3_URI = getUri(ROOT_3); mockWorkspace.roots = [ROOT_1_URI, ROOT_2_URI, ROOT_3_URI]; + mockWorkspace.configuration = uri.file(fixPath('/config')); mockConfigService.setUserConfiguration('search', { useRipgrep: true, @@ -385,6 +386,7 @@ suite('QueryBuilder', () => { test('relative includes w/two root folders', () => { const ROOT_2 = '/project/root2'; mockWorkspace.roots = [ROOT_1_URI, getUri(ROOT_2)]; + mockWorkspace.configuration = uri.file(fixPath('config')); [ [ @@ -424,6 +426,7 @@ suite('QueryBuilder', () => { const ROOT_2 = '/project/rootB'; const ROOT_3 = '/otherproject/rootB'; mockWorkspace.roots = [ROOT_1_URI, getUri(ROOT_2), getUri(ROOT_3)]; + mockWorkspace.configuration = uri.file(fixPath('/config')); [ [ diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index a6e0bbbf1536b7c8c229a28406478009a2e7785a..a9ffb50bf78e63ac10cd0eb9db682a6c47f56476 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -97,11 +97,11 @@ export class TestContextService implements IWorkspaceContextService { } public hasFolderWorkspace(): boolean { - return this.hasWorkspace(); + return this.workspace && !this.workspace.configuration; } public hasMultiFolderWorkspace(): boolean { - return false; + return this.workspace && !!this.workspace.configuration; } public getLegacyWorkspace(): ILegacyWorkspace {