提交 6531a5cf 编写于 作者: R Rob Lourens

Fix './' syntax when using a single-folder workspace

上级 8527af58
......@@ -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 !== '.') {
......
......@@ -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) {
......
......@@ -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'));
[
[
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册