diff --git a/src/vs/code/electron-main/menubar.ts b/src/vs/code/electron-main/menubar.ts index 1bbfd9834bb83d9b49a3ce4b6f9cd46089cd2168..9aca1cca19fa28279a88ad88161137681d3e7fef 100644 --- a/src/vs/code/electron-main/menubar.ts +++ b/src/vs/code/electron-main/menubar.ts @@ -19,7 +19,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base/common/labels'; import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows'; import { IHistoryMainService } from 'vs/platform/history/common/history'; -import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction } from 'vs/platform/menubar/common/menubar'; import URI from 'vs/base/common/uri'; import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; @@ -563,10 +563,10 @@ export class Menubar { let label: string; let uri: URI; if (isSingleFolderWorkspaceIdentifier(workspaceOrFile) && !isFile) { - label = unmnemonicLabel(getWorkspaceLabel(workspaceOrFile, this.environmentService, this.uriLabelService, { verbose: true })); + label = unmnemonicLabel(this.uriLabelService.getWorkspaceLabel(workspaceOrFile, { verbose: true })); uri = workspaceOrFile; } else if (isWorkspaceIdentifier(workspaceOrFile)) { - label = getWorkspaceLabel(workspaceOrFile, this.environmentService, this.uriLabelService, { verbose: true }); + label = this.uriLabelService.getWorkspaceLabel(workspaceOrFile, { verbose: true }); uri = URI.file(workspaceOrFile.configPath); } else { label = unmnemonicLabel(this.uriLabelService.getLabel(workspaceOrFile)); diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 0f11f0d2cb0af7ff333dbeee9d5329a39b9dc6f6..3a27ba9c4d80c894441e63bf21b03c76b4e10466 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -22,7 +22,7 @@ import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel } from 'vs/base import { KeybindingsResolver } from 'vs/code/electron-main/keyboard'; import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows'; import { IHistoryMainService } from 'vs/platform/history/common/history'; -import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import URI from 'vs/base/common/uri'; import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; @@ -491,10 +491,10 @@ export class CodeMenu { let label: string; let uri: URI; if (isSingleFolderWorkspaceIdentifier(workspace)) { - label = unmnemonicLabel(getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true })); + label = unmnemonicLabel(this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true })); uri = workspace; } else if (isWorkspaceIdentifier(workspace)) { - label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); + label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true }); uri = URI.file(workspace.configPath); } else { uri = URI.file(workspace); diff --git a/src/vs/platform/history/electron-main/historyMainService.ts b/src/vs/platform/history/electron-main/historyMainService.ts index 84f4d3146e5a8322782f97cd0a733b3dd3c3b21c..aaaeca45452771ce7f541b732e24b8ec6e8230d8 100644 --- a/src/vs/platform/history/electron-main/historyMainService.ts +++ b/src/vs/platform/history/electron-main/historyMainService.ts @@ -14,9 +14,8 @@ import { getBaseLabel } from 'vs/base/common/labels'; import { IPath } from 'vs/platform/windows/common/windows'; import { Event as CommonEvent, Emitter } from 'vs/base/common/event'; import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform'; -import { IWorkspaceIdentifier, IWorkspacesMainService, getWorkspaceLabel, IWorkspaceSavedEvent, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, IWorkspacesMainService, IWorkspaceSavedEvent, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common/history'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { isEqual } from 'vs/base/common/paths'; import { RunOnceScheduler } from 'vs/base/common/async'; import { getComparisonKey, isEqual as areResourcesEqual, dirname } from 'vs/base/common/resources'; @@ -52,7 +51,6 @@ export class HistoryMainService implements IHistoryMainService { @IStateService private stateService: IStateService, @ILogService private logService: ILogService, @IWorkspacesMainService private workspacesMainService: IWorkspacesMainService, - @IEnvironmentService private environmentService: IEnvironmentService, @IUriLabelService private uriLabelService: IUriLabelService ) { this.macOSRecentDocumentsUpdater = new RunOnceScheduler(() => this.updateMacOSRecentDocuments(), 800); @@ -368,7 +366,7 @@ export class HistoryMainService implements IHistoryMainService { type: 'custom', name: nls.localize('recentFolders', "Recent Workspaces"), items: this.getRecentlyOpened().workspaces.slice(0, 7 /* limit number of entries here */).map(workspace => { - const title = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); + const title = this.uriLabelService.getWorkspaceLabel(workspace); let description; let args; if (isSingleFolderWorkspaceIdentifier(workspace)) { diff --git a/src/vs/platform/workspaces/common/workspaces.ts b/src/vs/platform/workspaces/common/workspaces.ts index 5c8c389fc85e9cdf2874dc4bc12ff8bf7b8f6d06..44b42dde3255b733fa4bb4da2be501ba580ff28e 100644 --- a/src/vs/platform/workspaces/common/workspaces.ts +++ b/src/vs/platform/workspaces/common/workspaces.ts @@ -7,17 +7,10 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { TPromise } from 'vs/base/common/winjs.base'; -import { isParent } from 'vs/platform/files/common/files'; import { localize } from 'vs/nls'; -import { basename, dirname, join } from 'vs/base/common/paths'; -import { isLinux } from 'vs/base/common/platform'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { Event } from 'vs/base/common/event'; -import { getBaseLabel } from 'vs/base/common/labels'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import URI from 'vs/base/common/uri'; -import { Schemas } from 'vs/base/common/network'; -import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; export const IWorkspacesMainService = createDecorator('workspacesMainService'); export const IWorkspacesService = createDecorator('workspacesService'); @@ -113,34 +106,6 @@ export interface IWorkspacesService { createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise; } -export function getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), environmentService: IEnvironmentService, uriLabelService: IUriLabelService, options?: { verbose: boolean }): string { - - // Workspace: Single Folder - if (isSingleFolderWorkspaceIdentifier(workspace)) { - // Folder on disk - if (workspace.scheme === Schemas.file) { - return options && options.verbose ? uriLabelService.getLabel(workspace) : getBaseLabel(workspace); - } - - // Remote folder - return options && options.verbose ? uriLabelService.getLabel(workspace) : `${getBaseLabel(workspace)} (${workspace.scheme})`; - } - - // Workspace: Untitled - if (isParent(workspace.configPath, environmentService.workspacesHome, !isLinux /* ignore case */)) { - return localize('untitledWorkspace', "Untitled (Workspace)"); - } - - // Workspace: Saved - const filename = basename(workspace.configPath); - const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1); - if (options && options.verbose) { - return localize('workspaceNameVerbose', "{0} (Workspace)", uriLabelService.getLabel(URI.file(join(dirname(workspace.configPath), workspaceName)))); - } - - return localize('workspaceName', "{0} (Workspace)", workspaceName); -} - export function isSingleFolderWorkspaceIdentifier(obj: any): obj is ISingleFolderWorkspaceIdentifier { return obj instanceof URI; } diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index 1e22b3ed71b2d26a752ce37c2a4382f91cfc7184..676e4ab348a9cdfea4b99363d4fb75d633d21c45 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -25,8 +25,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { IDisposable, Disposable, dispose } from 'vs/base/common/lifecycle'; import { domEvent } from 'vs/base/browser/event'; import { IRecentlyOpened } from 'vs/platform/history/common/history'; -import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { RunOnceScheduler } from 'vs/base/common/async'; import { MENUBAR_SELECTION_FOREGROUND, MENUBAR_SELECTION_BACKGROUND, MENUBAR_SELECTION_BORDER, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, MENU_BACKGROUND, MENU_FOREGROUND, MENU_SELECTION_BACKGROUND, MENU_SELECTION_FOREGROUND, MENU_SELECTION_BORDER } from 'vs/workbench/common/theme'; import URI from 'vs/base/common/uri'; @@ -122,7 +121,6 @@ export class MenubarControl extends Disposable { @IContextKeyService private contextKeyService: IContextKeyService, @IKeybindingService private keybindingService: IKeybindingService, @IConfigurationService private configurationService: IConfigurationService, - @IEnvironmentService private environmentService: IEnvironmentService, @IUriLabelService private uriLabelService: IUriLabelService, @IUpdateService private updateService: IUpdateService ) { @@ -533,10 +531,10 @@ export class MenubarControl extends Disposable { let uri: URI; if (isSingleFolderWorkspaceIdentifier(workspace) && !isFile) { - label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); + label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true }); uri = workspace; } else if (isWorkspaceIdentifier(workspace)) { - label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService, { verbose: true }); + label = this.uriLabelService.getWorkspaceLabel(workspace, { verbose: true }); uri = URI.file(workspace.configPath); } else { uri = workspace; diff --git a/src/vs/workbench/electron-browser/actions.ts b/src/vs/workbench/electron-browser/actions.ts index bdd05d8bf604885479f782703b020131fa80ea9f..33500ca8c7ed402a559838e61d34594444273052 100644 --- a/src/vs/workbench/electron-browser/actions.ts +++ b/src/vs/workbench/electron-browser/actions.ts @@ -29,7 +29,7 @@ import { webFrame, shell } from 'electron'; import { getBaseLabel } from 'vs/base/common/labels'; import { IViewlet } from 'vs/workbench/common/viewlet'; import { IPanel } from 'vs/workbench/common/panel'; -import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { FileKind } from 'vs/platform/files/common/files'; import { IssueType } from 'vs/platform/issue/common/issue'; import { domEvent } from 'vs/base/browser/event'; @@ -441,11 +441,11 @@ export abstract class BaseOpenRecentAction extends Action { let description: string; if (isSingleFolderWorkspaceIdentifier(workspace) && fileKind !== FileKind.FILE) { resource = workspace; - label = getWorkspaceLabel(workspace, environmentService, uriLabelService); + label = uriLabelService.getWorkspaceLabel(workspace); description = uriLabelService.getLabel(dirname(resource)); } else if (isWorkspaceIdentifier(workspace)) { resource = URI.file(workspace.configPath); - label = getWorkspaceLabel(workspace, environmentService, uriLabelService); + label = uriLabelService.getWorkspaceLabel(workspace); description = uriLabelService.getLabel(dirname(resource)); } else { resource = workspace; diff --git a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts index 9ad196cfe57cdeb9bba5be3c7c4200ac932dd842..d0a84ee058ba39c0a2b0aca321f4a8ed1f0ec41e 100644 --- a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts +++ b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts @@ -33,8 +33,7 @@ import { registerThemingParticipant } from 'vs/platform/theme/common/themeServic import { registerColor, focusBorder, textLinkForeground, textLinkActiveForeground, foreground, descriptionForeground, contrastBorder, activeContrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { getExtraColor } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughUtils'; import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions'; -import { IStorageService } from 'vs/platform/storage/common/storage'; -import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IEditorInputFactory, EditorInput } from 'vs/workbench/common/editor'; import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; @@ -55,9 +54,7 @@ export class WelcomePageContribution implements IWorkbenchContribution { @IConfigurationService configurationService: IConfigurationService, @IEditorService editorService: IEditorService, @IBackupFileService backupFileService: IBackupFileService, - @ITelemetryService telemetryService: ITelemetryService, @ILifecycleService lifecycleService: ILifecycleService, - @IStorageService storageService: IStorageService ) { const enabled = isWelcomePageEnabled(configurationService); if (enabled && lifecycleService.startupKind !== StartupKind.ReloadedWindow) { @@ -283,9 +280,9 @@ class WelcomePage { let resource: URI; if (isSingleFolderWorkspaceIdentifier(workspace)) { resource = workspace; - label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); + label = this.uriLabelService.getWorkspaceLabel(workspace); } else if (isWorkspaceIdentifier(workspace)) { - label = getWorkspaceLabel(workspace, this.environmentService, this.uriLabelService); + label = this.uriLabelService.getWorkspaceLabel(workspace); resource = URI.file(workspace.configPath); } else { label = getBaseLabel(workspace);