Skip to content

Commit f6b8a27

Browse files
committed
workspaceSuffux also for workspace label
1 parent b5833eb commit f6b8a27

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/vs/base/common/labels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function getPathLabel(resource: URI | string, userHomeProvider?: IUserHom
3636
const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
3737

3838
let pathLabel: string;
39-
if (isEqual(baseResource.uri, resource, !isLinux)) {
39+
if (isEqual(baseResource.uri, resource)) {
4040
pathLabel = ''; // no label if paths are identical
4141
} else {
4242
// TODO: isidor use resources.relative

src/vs/workbench/services/label/common/labelService.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
1212
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1313
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
1414
import { isEqual, basenameOrAuthority, isEqualOrParent, basename, joinPath, dirname } from 'vs/base/common/resources';
15-
import { isLinux, isWindows } from 'vs/base/common/platform';
15+
import { isWindows } from 'vs/base/common/platform';
1616
import { tildify, getPathLabel } from 'vs/base/common/labels';
1717
import { ltrim, endsWith } from 'vs/base/common/strings';
1818
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
@@ -137,7 +137,7 @@ export class LabelService implements ILabelService {
137137

138138
if (options.relative && baseResource) {
139139
let relativeLabel: string;
140-
if (isEqual(baseResource.uri, resource, !isLinux)) {
140+
if (isEqual(baseResource.uri, resource)) {
141141
relativeLabel = ''; // no label if resources are identical
142142
} else {
143143
const baseResourceLabel = this.formatUri(baseResource.uri, formatting, options.noPrefix);
@@ -172,13 +172,7 @@ export class LabelService implements ILabelService {
172172
if (isSingleFolderWorkspaceIdentifier(workspace)) {
173173
// Folder on disk
174174
const label = options && options.verbose ? this.getUriLabel(workspace) : basename(workspace) || '/';
175-
if (workspace.scheme === Schemas.file) {
176-
return label;
177-
}
178-
179-
const formatting = this.findFormatting(workspace);
180-
const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : workspace.scheme;
181-
return suffix ? `${label} (${suffix})` : label;
175+
return this.appendWorkspaceSuffix(label, workspace);
182176
}
183177

184178
// Workspace: Untitled
@@ -189,11 +183,13 @@ export class LabelService implements ILabelService {
189183
// Workspace: Saved
190184
const filename = basename(workspace.configPath);
191185
const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
186+
let label;
192187
if (options && options.verbose) {
193-
return localize('workspaceNameVerbose', "{0} (Workspace)", this.getUriLabel(joinPath(dirname(workspace.configPath), workspaceName)));
188+
label = localize('workspaceNameVerbose', "{0} (Workspace)", this.getUriLabel(joinPath(dirname(workspace.configPath), workspaceName)));
189+
} else {
190+
label = localize('workspaceName', "{0} (Workspace)", workspaceName);
194191
}
195-
196-
return localize('workspaceName', "{0} (Workspace)", workspaceName);
192+
return this.appendWorkspaceSuffix(label, workspace.configPath);
197193
}
198194

199195
getSeparator(scheme: string, authority?: string): '/' | '\\' {
@@ -250,4 +246,14 @@ export class LabelService implements ILabelService {
250246
}
251247
return appendedLabel;
252248
}
249+
250+
private appendWorkspaceSuffix(label: string, uri: URI): string {
251+
if (uri.scheme === Schemas.file) {
252+
return label;
253+
}
254+
255+
const formatting = this.findFormatting(uri);
256+
const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : uri.scheme;
257+
return suffix ? `${label} (${suffix})` : label;
258+
}
253259
}

0 commit comments

Comments
 (0)