From 9acd33950e9862e7fe5439512ca3c1f50c04d473 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 22 Aug 2018 17:40:25 +0200 Subject: [PATCH 1/5] move uriLabelService to be a core service. Configuraion service depends on it, not the other way around --- src/vs/code/electron-main/main.ts | 2 +- .../standalone/browser/simpleServices.ts | 4 +++ src/vs/platform/uriLabel/common/uriLabel.ts | 36 +++++++++++++++++-- .../platform/uriLabel/test/uriLabel.test.ts | 7 ++-- src/vs/workbench/electron-browser/main.ts | 12 ++++--- src/vs/workbench/electron-browser/shell.ts | 5 +++ .../workbench/electron-browser/workbench.ts | 6 ---- .../node/configurationService.ts | 15 +++----- .../configurationEditingService.test.ts | 3 +- .../configurationService.test.ts | 16 ++++++--- .../api/mainThreadEditors.test.ts | 4 +-- .../workbench/test/workbenchTestServices.ts | 2 +- 12 files changed, 76 insertions(+), 36 deletions(-) diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index dbe95eb11e2..5f09b85b211 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -58,7 +58,7 @@ function createServices(args: ParsedArgs, bufferLogService: BufferLogService): I const environmentService = new EnvironmentService(args, process.execPath); const consoleLogService = new ConsoleLogMainService(getLogLevel(environmentService)); const logService = new MultiplexLogService([consoleLogService, bufferLogService]); - const uriLabelService = new UriLabelService(environmentService, undefined); + const uriLabelService = new UriLabelService(environmentService); process.once('exit', () => logService.dispose()); diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index e73c429819f..46b76c734f8 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -609,6 +609,10 @@ export class SimpleUriLabelService implements IUriLabelService { return resource.path; } + public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI, options?: { verbose: boolean; }): string { + throw new Error('Not implemented'); + } + public registerFormater(schema: string, formater: UriLabelRules): IDisposable { throw new Error('Not implemented'); } diff --git a/src/vs/platform/uriLabel/common/uriLabel.ts b/src/vs/platform/uriLabel/common/uriLabel.ts index 4cd0e873aa2..f59ae2cb4b0 100644 --- a/src/vs/platform/uriLabel/common/uriLabel.ts +++ b/src/vs/platform/uriLabel/common/uriLabel.ts @@ -13,10 +13,15 @@ import { isEqual, basenameOrAuthority } from 'vs/base/common/resources'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { tildify, getPathLabel } from 'vs/base/common/labels'; import { ltrim } from 'vs/base/common/strings'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; +import { localize } from 'vs/nls'; +import { isParent } from 'vs/platform/files/common/files'; +import { basename, dirname, join } from 'vs/base/common/paths'; export interface IUriLabelService { _serviceBrand: any; getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string; + getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string; registerFormater(schema: string, formater: UriLabelRules): IDisposable; onDidRegisterFormater: Event<{ scheme: string, formater: UriLabelRules }>; } @@ -41,18 +46,21 @@ export class UriLabelService implements IUriLabelService { private readonly formaters = new Map(); private readonly _onDidRegisterFormater = new Emitter<{ scheme: string, formater: UriLabelRules }>(); + private contextService: IWorkspaceContextService; constructor( @IEnvironmentService private environmentService: IEnvironmentService, - @IWorkspaceContextService private contextService: IWorkspaceContextService ) { } - get onDidRegisterFormater(): Event<{ scheme: string, formater: UriLabelRules }> { return this._onDidRegisterFormater.event; } - getLabel(resource: URI, relative: boolean, forceNoTildify?: boolean): string { + acquireContextService(contextService: IWorkspaceContextService): void { + this.contextService = contextService; + } + + getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string { if (!resource) { return undefined; } @@ -85,6 +93,28 @@ export class UriLabelService implements IUriLabelService { return this.formatUri(resource, formater, forceNoTildify); } + getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string { + // Workspace: Single Folder + if (isSingleFolderWorkspaceIdentifier(workspace)) { + // Folder on disk + return options && options.verbose ? this.getLabel(workspace) : basenameOrAuthority(workspace); + } + + // Workspace: Untitled + if (isParent(workspace.configPath, this.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)", this.getLabel(URI.file(join(dirname(workspace.configPath), workspaceName)))); + } + + return localize('workspaceName', "{0} (Workspace)", workspaceName); + } + registerFormater(scheme: string, formater: UriLabelRules): IDisposable { this.formaters.set(scheme, formater); this._onDidRegisterFormater.fire({ scheme, formater }); diff --git a/src/vs/platform/uriLabel/test/uriLabel.test.ts b/src/vs/platform/uriLabel/test/uriLabel.test.ts index 8b36579e453..4c82a0d0eaf 100644 --- a/src/vs/platform/uriLabel/test/uriLabel.test.ts +++ b/src/vs/platform/uriLabel/test/uriLabel.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import { IUriLabelService, UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; +import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; import { TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; import { Schemas } from 'vs/base/common/network'; import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; @@ -14,10 +14,11 @@ import { isWindows } from 'vs/base/common/platform'; suite('URI Label', () => { - let uriLabelService: IUriLabelService; + let uriLabelService: UriLabelService; setup(() => { - uriLabelService = new UriLabelService(TestEnvironmentService, new TestContextService()); + uriLabelService = new UriLabelService(TestEnvironmentService); + uriLabelService.acquireContextService(new TestContextService()); }); test('file scheme', function () { diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 08edc11b168..43fe84321a2 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -48,6 +48,7 @@ import { RelayURLService } from 'vs/platform/url/common/urlService'; import { MenubarChannelClient } from 'vs/platform/menubar/node/menubarIpc'; import { IMenubarService } from 'vs/platform/menubar/common/menubar'; import { Schemas } from 'vs/base/common/network'; +import { IUriLabelService, UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; gracefulFs.gracefulify(fs); // enable gracefulFs @@ -98,13 +99,15 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { const mainServices = createMainProcessServices(mainProcessClient, configuration); const environmentService = new EnvironmentService(configuration, configuration.execPath); + const uriLabelService = new UriLabelService(environmentService); const logService = createLogService(mainProcessClient, configuration, environmentService); logService.trace('openWorkbench configuration', JSON.stringify(configuration)); // Since the configuration service is one of the core services that is used in so many places, we initialize it // right before startup of the workbench shell to have its data ready for consumers - return createAndInitializeWorkspaceService(configuration, environmentService).then(workspaceService => { + return createAndInitializeWorkspaceService(configuration, environmentService, uriLabelService).then(workspaceService => { const storageService = createStorageService(workspaceService, environmentService); + uriLabelService.acquireContextService(workspaceService); return domContentLoaded().then(() => { @@ -115,7 +118,8 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { configurationService: workspaceService, environmentService, logService, - storageService + storageService, + uriLabelService }, mainServices, mainProcessClient, configuration); shell.open(); @@ -131,10 +135,10 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { }); } -function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService): TPromise { +function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService, uriLabelService: IUriLabelService): TPromise { return validateFolderUri(configuration.folderUri, configuration.verbose).then(validatedFolderUri => { - const workspaceService = new WorkspaceService(environmentService); + const workspaceService = new WorkspaceService(environmentService, uriLabelService); return workspaceService.initialize(configuration.workspace || validatedFolderUri || configuration).then(() => workspaceService, error => workspaceService); }); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index ae688e469bf..594153f133d 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -98,6 +98,7 @@ import { ExtensionManagementServerService } from 'vs/workbench/services/extensio import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc'; import { DefaultURITransformer } from 'vs/base/common/uriIpc'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService'; +import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; /** * Services that we require for the Shell @@ -108,6 +109,7 @@ export interface ICoreServices { environmentService: IEnvironmentService; logService: ILogService; storageService: IStorageService; + uriLabelService: IUriLabelService; } /** @@ -117,6 +119,7 @@ export interface ICoreServices { export class WorkbenchShell extends Disposable { private storageService: IStorageService; private environmentService: IEnvironmentService; + private uriLabelService: IUriLabelService; private logService: ILogService; private configurationService: IConfigurationService; private contextService: IWorkspaceContextService; @@ -145,6 +148,7 @@ export class WorkbenchShell extends Disposable { this.contextService = coreServices.contextService; this.configurationService = coreServices.configurationService; this.environmentService = coreServices.environmentService; + this.uriLabelService = coreServices.uriLabelService; this.logService = coreServices.logService; this.storageService = coreServices.storageService; @@ -316,6 +320,7 @@ export class WorkbenchShell extends Disposable { serviceCollection.set(IWorkspaceContextService, this.contextService); serviceCollection.set(IConfigurationService, this.configurationService); serviceCollection.set(IEnvironmentService, this.environmentService); + serviceCollection.set(IUriLabelService, this.uriLabelService); serviceCollection.set(ILogService, this._register(this.logService)); serviceCollection.set(IStorageService, this.storageService); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 5a3ee22e21c..51f863b673a 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -116,7 +116,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; import { WorkbenchThemeService } from 'vs/workbench/services/themes/electron-browser/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; -import { IUriLabelService, UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; interface WorkbenchParams { configuration: IWindowConfiguration; @@ -336,11 +335,6 @@ export class Workbench extends Disposable implements IPartService { // Clipboard serviceCollection.set(IClipboardService, new ClipboardService()); - // Uri Display - const uriLabelService = new UriLabelService(this.environmentService, this.contextService); - serviceCollection.set(IUriLabelService, uriLabelService); - this.configurationService.acquireUriLabelService(uriLabelService); - // Status bar this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); this._register(toDisposable(() => this.statusbarPart.shutdown())); diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index eb73870a0be..340c8499127 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -26,7 +26,7 @@ import { IWorkspaceConfigurationService, FOLDER_CONFIG_FOLDER_NAME, defaultSetti import { Registry } from 'vs/platform/registry/common/platform'; import { IConfigurationNode, IConfigurationRegistry, Extensions, IConfigurationPropertySchema, allSettings, windowSettings, resourceSettings, applicationSettings } from 'vs/platform/configuration/common/configurationRegistry'; import { createHash } from 'crypto'; -import { getWorkspaceLabel, IWorkspaceIdentifier, isWorkspaceIdentifier, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, isWorkspaceIdentifier, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ICommandService } from 'vs/platform/commands/common/commands'; @@ -69,11 +69,10 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat public readonly onDidChangeWorkbenchState: Event = this._onDidChangeWorkbenchState.event; private fileService: IFileService; - private uriLabelService: IUriLabelService; private configurationEditingService: ConfigurationEditingService; private jsonEditingService: JSONEditingService; - constructor(private environmentService: IEnvironmentService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) { + constructor(private environmentService: IEnvironmentService, private uriLabelService: IUriLabelService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) { super(); this.defaultConfiguration = new DefaultConfigurationModel(); @@ -319,10 +318,6 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat }); } - acquireUriLabelService(uriLabelService: IUriLabelService): void { - this.uriLabelService = uriLabelService; - } - acquireInstantiationService(instantiationService: IInstantiationService): void { this.configurationEditingService = instantiationService.createInstance(ConfigurationEditingService); this.jsonEditingService = instantiationService.createInstance(JSONEditingService); @@ -346,7 +341,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat .then(() => { const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(workspaceConfigPath.fsPath))); const workspaceId = workspaceIdentifier.id; - const workspaceName = getWorkspaceLabel({ id: workspaceId, configPath: workspaceConfigPath.fsPath }, this.environmentService, this.uriLabelService); + const workspaceName = this.uriLabelService.getWorkspaceLabel({ id: workspaceId, configPath: workspaceConfigPath.fsPath }); return new Workspace(workspaceId, workspaceName, workspaceFolders, workspaceConfigPath); }); } @@ -369,11 +364,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat } const id = createHash('md5').update(folder.fsPath).update(ctime ? String(ctime) : '').digest('hex'); - return new Workspace(id, getWorkspaceLabel(folder, this.environmentService, this.uriLabelService), toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime); + return new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime); }); } else { const id = createHash('md5').update(folder.toString()).digest('hex'); - return TPromise.as(new Workspace(id, getWorkspaceLabel(folder, this.environmentService, this.uriLabelService), toWorkspaceFolders([{ uri: folder.toString() }]), null)); + return TPromise.as(new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ uri: folder.toString() }]), null)); } } diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts index a6ab72cead7..f201f562127 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts @@ -39,6 +39,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { ICommandService } from 'vs/platform/commands/common/commands'; import { CommandService } from 'vs/workbench/services/commands/common/commandService'; import URI from 'vs/base/common/uri'; +import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -102,7 +103,7 @@ suite('ConfigurationEditingService', () => { instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); instantiationService.stub(IEnvironmentService, environmentService); - const workspaceService = new WorkspaceService(environmentService); + const workspaceService = new WorkspaceService(environmentService, new UriLabelService(environmentService)); instantiationService.stub(IWorkspaceContextService, workspaceService); return workspaceService.initialize(noWorkspace ? {} as IWindowConfiguration : URI.file(workspaceDir)).then(() => { instantiationService.stub(IConfigurationService, workspaceService); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index 64e9352f99a..d4bc36c32d6 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -35,6 +35,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/ import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -86,7 +87,8 @@ suite('WorkspaceContextService - Folder', () => { workspaceResource = folderDir; const globalSettingsFile = path.join(parentDir, 'settings.json'); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - workspaceContextService = new WorkspaceService(environmentService); + const uriLabelService = new UriLabelService(environmentService); + workspaceContextService = new WorkspaceService(environmentService, uriLabelService); return (workspaceContextService).initialize(URI.file(folderDir)); }); }); @@ -143,7 +145,8 @@ suite('WorkspaceContextService - Workspace', () => { parentResource = parentDir; const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); - const workspaceService = new WorkspaceService(environmentService); + const uriLabelService = new UriLabelService(environmentService); + const workspaceService = new WorkspaceService(environmentService, uriLabelService); const instantiationService = workbenchInstantiationService(); instantiationService.stub(IWorkspaceContextService, workspaceService); @@ -406,7 +409,8 @@ suite('WorkspaceService - Initialization', () => { const instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - const workspaceService = new WorkspaceService(environmentService); + const uriLabelService = new UriLabelService(environmentService); + const workspaceService = new WorkspaceService(environmentService, uriLabelService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -661,7 +665,8 @@ suite('WorkspaceConfigurationService - Folder', () => { const instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - const workspaceService = new WorkspaceService(environmentService); + const uriLabelService = new UriLabelService(environmentService); + const workspaceService = new WorkspaceService(environmentService, uriLabelService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -936,7 +941,8 @@ suite('WorkspaceConfigurationService-Multiroot', () => { parentResource = parentDir; environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); - const workspaceService = new WorkspaceService(environmentService); + const uriLabelService = new UriLabelService(environmentService); + const workspaceService = new WorkspaceService(environmentService, uriLabelService); const instantiationService = workbenchInstantiationService(); instantiationService.stub(IWorkspaceContextService, workspaceService); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 19ef6688f08..0013574b689 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -21,7 +21,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; import { IModelService } from 'vs/editor/common/services/modelService'; import { EditOperation } from 'vs/editor/common/core/editOperation'; -import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; +import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices'; import { TPromise } from 'vs/base/common/winjs.base'; import { ResourceTextEdit } from 'vs/editor/common/modes'; import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService'; @@ -84,7 +84,7 @@ suite('MainThreadEditors', () => { } }; - const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService, new TestContextService())); + const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService)); const rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock() { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 28b58ffa681..16c593921a9 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -271,7 +271,7 @@ export function workbenchInstantiationService(): IInstantiationService { instantiationService.stub(IHashService, new TestHashService()); instantiationService.stub(ILogService, new TestLogService()); instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)])); - instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService, workspaceContextService)); + instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService)); const editorService = new TestEditorService(); instantiationService.stub(IEditorService, editorService); instantiationService.stub(ICodeEditorService, new TestCodeEditorService()); From 63eb72070883c11f248428ead557265550b4aa4b Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 22 Aug 2018 17:40:57 +0200 Subject: [PATCH 2/5] get rid of getWorkspaceLabel in workspaces.ts and adopt --- src/vs/code/electron-main/menubar.ts | 6 ++-- src/vs/code/electron-main/menus.ts | 6 ++-- .../electron-main/historyMainService.ts | 6 ++-- .../platform/workspaces/common/workspaces.ts | 35 ------------------- .../browser/parts/titlebar/menubarControl.ts | 8 ++--- src/vs/workbench/electron-browser/actions.ts | 6 ++-- .../page/electron-browser/welcomePage.ts | 9 ++--- 7 files changed, 17 insertions(+), 59 deletions(-) diff --git a/src/vs/code/electron-main/menubar.ts b/src/vs/code/electron-main/menubar.ts index 1bbfd9834bb..9aca1cca19f 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 0f11f0d2cb0..3a27ba9c4d8 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 84f4d3146e5..aaaeca45452 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 5c8c389fc85..44b42dde325 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 1e22b3ed71b..676e4ab348a 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 bdd05d8bf60..33500ca8c7e 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 9ad196cfe57..d0a84ee058b 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); From 6090860b4f8076e75c19d9b81bc97d6c24eae97d Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 23 Aug 2018 11:59:31 +0200 Subject: [PATCH 3/5] workspaces: toWorkspaceIdentifier utility --- src/vs/platform/workspaces/common/workspaces.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/workspaces/common/workspaces.ts b/src/vs/platform/workspaces/common/workspaces.ts index 44b42dde325..9384c7bd4c1 100644 --- a/src/vs/platform/workspaces/common/workspaces.ts +++ b/src/vs/platform/workspaces/common/workspaces.ts @@ -9,7 +9,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { TPromise } from 'vs/base/common/winjs.base'; import { localize } from 'vs/nls'; import { Event } from 'vs/base/common/event'; -import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; +import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; import URI from 'vs/base/common/uri'; export const IWorkspacesMainService = createDecorator('workspacesMainService'); @@ -115,3 +115,18 @@ export function isWorkspaceIdentifier(obj: any): obj is IWorkspaceIdentifier { return workspaceIdentifier && typeof workspaceIdentifier.id === 'string' && typeof workspaceIdentifier.configPath === 'string'; } + +export function toWorkspaceIdentifier(workspace: IWorkspace): IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined { + if (workspace.configuration) { + return { + configPath: workspace.configuration.fsPath, + id: workspace.id + }; + } + if (workspace.folders.length === 1) { + return workspace.folders[0].uri; + } + + // Empty workspace + return undefined; +} From a03b3b5066642ac0d2a6db8c7b3efe6f47ed83d8 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 23 Aug 2018 11:59:51 +0200 Subject: [PATCH 4/5] remove .name from IWorkspace --- src/vs/code/electron-main/main.ts | 2 +- .../standalone/browser/simpleServices.ts | 6 ++--- src/vs/platform/uriLabel/common/uriLabel.ts | 22 +++++++++++-------- .../platform/uriLabel/test/uriLabel.test.ts | 3 +-- src/vs/platform/workspace/common/workspace.ts | 18 +-------------- .../workspace/test/common/testWorkspace.ts | 3 +-- .../workspace/test/common/workspace.test.ts | 8 +++---- .../electron-browser/mainThreadWorkspace.ts | 12 ++++++++-- src/vs/workbench/api/node/extHost.api.impl.ts | 2 +- src/vs/workbench/api/node/extHostWorkspace.ts | 12 ++++++++-- .../browser/parts/titlebar/titlebarPart.ts | 2 +- src/vs/workbench/electron-browser/main.ts | 12 ++++------ src/vs/workbench/electron-browser/shell.ts | 2 -- .../workbench/electron-browser/workbench.ts | 5 +++++ .../files/electron-browser/views/emptyView.ts | 2 +- .../electron-browser/views/explorerView.ts | 6 +++-- .../logs/electron-browser/logsActions.ts | 15 ++++++++----- .../search/test/common/queryBuilder.test.ts | 2 +- .../backupFileService.test.ts | 2 +- .../node/configurationService.ts | 10 ++++----- .../test/common/configurationModels.test.ts | 2 +- .../configurationEditingService.test.ts | 3 +-- .../configurationService.test.ts | 16 +++++--------- .../electron-browser/extensionHost.ts | 14 +++++++++--- .../test/electron-browser/fileService.test.ts | 8 +++---- .../keybindingEditing.test.ts | 2 +- .../parts/editor/breadcrumbModel.test.ts | 2 +- .../api/mainThreadEditors.test.ts | 4 ++-- .../workbench/test/workbenchTestServices.ts | 2 +- 29 files changed, 103 insertions(+), 96 deletions(-) diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 5f09b85b211..dbe95eb11e2 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -58,7 +58,7 @@ function createServices(args: ParsedArgs, bufferLogService: BufferLogService): I const environmentService = new EnvironmentService(args, process.execPath); const consoleLogService = new ConsoleLogMainService(getLogLevel(environmentService)); const logService = new MultiplexLogService([consoleLogService, bufferLogService]); - const uriLabelService = new UriLabelService(environmentService); + const uriLabelService = new UriLabelService(environmentService, undefined); process.once('exit', () => logService.dispose()); diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 46b76c734f8..2bd024ca87d 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -508,7 +508,7 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { constructor() { const resource = URI.from({ scheme: SimpleWorkspaceContextService.SCHEME, authority: 'model', path: '/' }); - this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })], name: resource.fsPath }; + this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })] }; } public getWorkspace(): IWorkspace { @@ -609,8 +609,8 @@ export class SimpleUriLabelService implements IUriLabelService { return resource.path; } - public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI, options?: { verbose: boolean; }): string { - throw new Error('Not implemented'); + public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI | IWorkspace, options?: { verbose: boolean; }): string { + return ''; } public registerFormater(schema: string, formater: UriLabelRules): IDisposable { diff --git a/src/vs/platform/uriLabel/common/uriLabel.ts b/src/vs/platform/uriLabel/common/uriLabel.ts index f59ae2cb4b0..f676d7582ea 100644 --- a/src/vs/platform/uriLabel/common/uriLabel.ts +++ b/src/vs/platform/uriLabel/common/uriLabel.ts @@ -7,13 +7,13 @@ import URI from 'vs/base/common/uri'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Event, Emitter } from 'vs/base/common/event'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { isEqual, basenameOrAuthority } from 'vs/base/common/resources'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { tildify, getPathLabel } from 'vs/base/common/labels'; import { ltrim } from 'vs/base/common/strings'; -import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { localize } from 'vs/nls'; import { isParent } from 'vs/platform/files/common/files'; import { basename, dirname, join } from 'vs/base/common/paths'; @@ -21,7 +21,7 @@ import { basename, dirname, join } from 'vs/base/common/paths'; export interface IUriLabelService { _serviceBrand: any; getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string; - getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string; + getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace), options?: { verbose: boolean }): string; registerFormater(schema: string, formater: UriLabelRules): IDisposable; onDidRegisterFormater: Event<{ scheme: string, formater: UriLabelRules }>; } @@ -46,20 +46,16 @@ export class UriLabelService implements IUriLabelService { private readonly formaters = new Map(); private readonly _onDidRegisterFormater = new Emitter<{ scheme: string, formater: UriLabelRules }>(); - private contextService: IWorkspaceContextService; constructor( @IEnvironmentService private environmentService: IEnvironmentService, + @IWorkspaceContextService private contextService: IWorkspaceContextService ) { } get onDidRegisterFormater(): Event<{ scheme: string, formater: UriLabelRules }> { return this._onDidRegisterFormater.event; } - acquireContextService(contextService: IWorkspaceContextService): void { - this.contextService = contextService; - } - getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string { if (!resource) { return undefined; @@ -93,7 +89,14 @@ export class UriLabelService implements IUriLabelService { return this.formatUri(resource, formater, forceNoTildify); } - getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string { + getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace), options?: { verbose: boolean }): string { + if (!isWorkspaceIdentifier(workspace) && !isSingleFolderWorkspaceIdentifier(workspace)) { + workspace = toWorkspaceIdentifier(workspace); + if (!workspace) { + return ''; + } + } + // Workspace: Single Folder if (isSingleFolderWorkspaceIdentifier(workspace)) { // Folder on disk @@ -106,6 +109,7 @@ export class UriLabelService implements IUriLabelService { } // Workspace: Saved + console.log(workspace.configPath); const filename = basename(workspace.configPath); const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1); if (options && options.verbose) { diff --git a/src/vs/platform/uriLabel/test/uriLabel.test.ts b/src/vs/platform/uriLabel/test/uriLabel.test.ts index 4c82a0d0eaf..6efc8d528e9 100644 --- a/src/vs/platform/uriLabel/test/uriLabel.test.ts +++ b/src/vs/platform/uriLabel/test/uriLabel.test.ts @@ -17,8 +17,7 @@ suite('URI Label', () => { let uriLabelService: UriLabelService; setup(() => { - uriLabelService = new UriLabelService(TestEnvironmentService); - uriLabelService.acquireContextService(new TestContextService()); + uriLabelService = new UriLabelService(TestEnvironmentService, new TestContextService()); }); test('file scheme', function () { diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 35d10686eb3..dcb2ca53a05 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -81,7 +81,6 @@ export namespace IWorkspace { export function isIWorkspace(thing: any): thing is IWorkspace { return thing && typeof thing === 'object' && typeof (thing as IWorkspace).id === 'string' - && typeof (thing as IWorkspace).name === 'string' && Array.isArray((thing as IWorkspace).folders); } } @@ -93,11 +92,6 @@ export interface IWorkspace { */ readonly id: string; - /** - * the name of the workspace. - */ - readonly name: string; - /** * Folders in the workspace. */ @@ -151,7 +145,6 @@ export class Workspace implements IWorkspace { constructor( private _id: string, - private _name: string = '', folders: WorkspaceFolder[] = [], private _configuration: URI = null, private _ctime?: number @@ -161,7 +154,6 @@ export class Workspace implements IWorkspace { update(workspace: Workspace) { this._id = workspace.id; - this._name = workspace.name; this._configuration = workspace.configuration; this._ctime = workspace.ctime; this.folders = workspace.folders; @@ -184,14 +176,6 @@ export class Workspace implements IWorkspace { return this._ctime; } - get name(): string { - return this._name; - } - - set name(name: string) { - this._name = name; - } - get configuration(): URI { return this._configuration; } @@ -216,7 +200,7 @@ export class Workspace implements IWorkspace { } toJSON(): IWorkspace { - return { id: this.id, folders: this.folders, name: this.name, configuration: this.configuration }; + return { id: this.id, folders: this.folders, configuration: this.configuration }; } } diff --git a/src/vs/platform/workspace/test/common/testWorkspace.ts b/src/vs/platform/workspace/test/common/testWorkspace.ts index 6a204873e0c..2fa9cd57e6e 100644 --- a/src/vs/platform/workspace/test/common/testWorkspace.ts +++ b/src/vs/platform/workspace/test/common/testWorkspace.ts @@ -13,7 +13,6 @@ export const TestWorkspace = testWorkspace(wsUri); export function testWorkspace(resource: URI): Workspace { return new Workspace( resource.toString(), - resource.fsPath, toWorkspaceFolders([{ path: resource.fsPath }]) ); -} \ No newline at end of file +} diff --git a/src/vs/platform/workspace/test/common/workspace.test.ts b/src/vs/platform/workspace/test/common/workspace.test.ts index ac6f0caf17f..58f24f3f4e4 100644 --- a/src/vs/platform/workspace/test/common/workspace.test.ts +++ b/src/vs/platform/workspace/test/common/workspace.test.ts @@ -14,7 +14,7 @@ suite('Workspace', () => { test('getFolder returns the folder with given uri', () => { const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 2 }); - let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), expected, new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]); + let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), expected, new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]); const actual = testObject.getFolder(expected.uri); @@ -23,7 +23,7 @@ suite('Workspace', () => { test('getFolder returns the folder if the uri is sub', () => { const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 }); - let testObject = new Workspace('', '', [expected, new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 1 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]); + let testObject = new Workspace('', [expected, new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 1 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]); const actual = testObject.getFolder(URI.file('/src/test/a')); @@ -32,7 +32,7 @@ suite('Workspace', () => { test('getFolder returns the closest folder if the uri is sub', () => { const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 2 }); - let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 }), expected]); + let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 }), expected]); const actual = testObject.getFolder(URI.file('/src/test/a')); @@ -40,7 +40,7 @@ suite('Workspace', () => { }); test('getFolder returns null if the uri is not sub', () => { - let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 })]); + let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 })]); const actual = testObject.getFolder(URI.file('/src/main/a')); diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index e797ba2ba0b..03f782d04e2 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -23,6 +23,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { IWindowService } from 'vs/platform/windows/common/windows'; +import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; @extHostNamedCustomer(MainContext.MainThreadWorkspace) export class MainThreadWorkspace implements MainThreadWorkspaceShape { @@ -40,6 +41,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { @IWorkspaceEditingService private readonly _workspaceEditingService: IWorkspaceEditingService, @IStatusbarService private readonly _statusbarService: IStatusbarService, @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IUriLabelService private readonly _uriLabelService: IUriLabelService ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostWorkspace); this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose); @@ -99,7 +101,13 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { } private _onDidChangeWorkspace(): void { - this._proxy.$acceptWorkspaceData(this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace()); + const workspace = this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace(); + this._proxy.$acceptWorkspaceData(workspace ? { + configuration: workspace.configuration, + folders: workspace.folders, + id: workspace.id, + name: this._uriLabelService.getWorkspaceLabel(workspace) + } : null); } // --- search --- @@ -230,4 +238,4 @@ CommandsRegistry.registerCommand('_workbench.enterWorkspace', async function (ac } return workspaceEditingService.enterWorkspace(workspace.fsPath); -}); \ No newline at end of file +}); diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 8bf889401c0..59aced91890 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -485,7 +485,7 @@ export function createApiFactory( return extHostWorkspace.getWorkspaceFolders(); }, get name() { - return extHostWorkspace.workspace ? extHostWorkspace.workspace.name : undefined; + return extHostWorkspace.name; }, set name(value) { throw errors.readonly(); diff --git a/src/vs/workbench/api/node/extHostWorkspace.ts b/src/vs/workbench/api/node/extHostWorkspace.ts index 56e9d91c15c..e15ee1d920e 100644 --- a/src/vs/workbench/api/node/extHostWorkspace.ts +++ b/src/vs/workbench/api/node/extHostWorkspace.ts @@ -107,8 +107,8 @@ class ExtHostWorkspaceImpl extends Workspace { private readonly _workspaceFolders: vscode.WorkspaceFolder[] = []; private readonly _structure = TernarySearchTree.forPaths(); - private constructor(id: string, name: string, folders: vscode.WorkspaceFolder[]) { - super(id, name, folders.map(f => new WorkspaceFolder(f))); + private constructor(id: string, private _name: string, folders: vscode.WorkspaceFolder[]) { + super(id, folders.map(f => new WorkspaceFolder(f))); // setup the workspace folder data structure folders.forEach(folder => { @@ -117,6 +117,10 @@ class ExtHostWorkspaceImpl extends Workspace { }); } + get name(): string { + return this._name; + } + get workspaceFolders(): vscode.WorkspaceFolder[] { return this._workspaceFolders.slice(0); } @@ -166,6 +170,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape { return this._actualWorkspace; } + get name(): string { + return this._actualWorkspace ? this._actualWorkspace.name : undefined; + } + private get _actualWorkspace(): ExtHostWorkspaceImpl { return this._unconfirmedWorkspace || this._confirmedWorkspace; } diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 9a4bc78f8bf..597f47f2881 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -243,7 +243,7 @@ export class TitlebarPart extends Part implements ITitleService { const activeEditorShort = editor ? editor.getTitle(Verbosity.SHORT) : ''; const activeEditorMedium = editor ? editor.getTitle(Verbosity.MEDIUM) : activeEditorShort; const activeEditorLong = editor ? editor.getTitle(Verbosity.LONG) : activeEditorMedium; - const rootName = workspace.name; + const rootName = root ? this.uriLabelService.getWorkspaceLabel(root) : ''; const rootPath = root ? this.uriLabelService.getLabel(root) : ''; const folderName = folder ? folder.name : ''; const folderPath = folder ? this.uriLabelService.getLabel(folder.uri) : ''; diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 43fe84321a2..08edc11b168 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -48,7 +48,6 @@ import { RelayURLService } from 'vs/platform/url/common/urlService'; import { MenubarChannelClient } from 'vs/platform/menubar/node/menubarIpc'; import { IMenubarService } from 'vs/platform/menubar/common/menubar'; import { Schemas } from 'vs/base/common/network'; -import { IUriLabelService, UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; gracefulFs.gracefulify(fs); // enable gracefulFs @@ -99,15 +98,13 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { const mainServices = createMainProcessServices(mainProcessClient, configuration); const environmentService = new EnvironmentService(configuration, configuration.execPath); - const uriLabelService = new UriLabelService(environmentService); const logService = createLogService(mainProcessClient, configuration, environmentService); logService.trace('openWorkbench configuration', JSON.stringify(configuration)); // Since the configuration service is one of the core services that is used in so many places, we initialize it // right before startup of the workbench shell to have its data ready for consumers - return createAndInitializeWorkspaceService(configuration, environmentService, uriLabelService).then(workspaceService => { + return createAndInitializeWorkspaceService(configuration, environmentService).then(workspaceService => { const storageService = createStorageService(workspaceService, environmentService); - uriLabelService.acquireContextService(workspaceService); return domContentLoaded().then(() => { @@ -118,8 +115,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { configurationService: workspaceService, environmentService, logService, - storageService, - uriLabelService + storageService }, mainServices, mainProcessClient, configuration); shell.open(); @@ -135,10 +131,10 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise { }); } -function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService, uriLabelService: IUriLabelService): TPromise { +function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService): TPromise { return validateFolderUri(configuration.folderUri, configuration.verbose).then(validatedFolderUri => { - const workspaceService = new WorkspaceService(environmentService, uriLabelService); + const workspaceService = new WorkspaceService(environmentService); return workspaceService.initialize(configuration.workspace || validatedFolderUri || configuration).then(() => workspaceService, error => workspaceService); }); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 594153f133d..4b366a0299c 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -109,7 +109,6 @@ export interface ICoreServices { environmentService: IEnvironmentService; logService: ILogService; storageService: IStorageService; - uriLabelService: IUriLabelService; } /** @@ -148,7 +147,6 @@ export class WorkbenchShell extends Disposable { this.contextService = coreServices.contextService; this.configurationService = coreServices.configurationService; this.environmentService = coreServices.environmentService; - this.uriLabelService = coreServices.uriLabelService; this.logService = coreServices.logService; this.storageService = coreServices.storageService; diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 51f863b673a..851611cc3b3 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -116,6 +116,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; import { WorkbenchThemeService } from 'vs/workbench/services/themes/electron-browser/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { UriLabelService, IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; interface WorkbenchParams { configuration: IWindowConfiguration; @@ -335,6 +336,10 @@ export class Workbench extends Disposable implements IPartService { // Clipboard serviceCollection.set(IClipboardService, new ClipboardService()); + // Uri Display + const uriLabelService = new UriLabelService(this.environmentService, this.contextService); + serviceCollection.set(IUriLabelService, uriLabelService); + // Status bar this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); this._register(toDisposable(() => this.statusbarPart.shutdown())); diff --git a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts index f7ab5bd7f54..46326cd24ee 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts @@ -103,7 +103,7 @@ export class EmptyView extends ViewletPanel { if (this.button) { this.button.label = nls.localize('addFolder', "Add Folder"); } - this.titleDiv.text(this.contextService.getWorkspace().name); + this.titleDiv.text(EmptyView.NAME); } else { this.messageDiv.text(nls.localize('noFolderHelp', "You have not yet opened a folder.")); if (this.button) { diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts index 09e0a417b5f..59f058f4c0b 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts @@ -43,6 +43,7 @@ import { Schemas } from 'vs/base/common/network'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet'; +import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; export interface IExplorerViewOptions extends IViewletViewOptions { viewletState: FileViewletState; @@ -94,7 +95,8 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView @IKeybindingService keybindingService: IKeybindingService, @IContextKeyService contextKeyService: IContextKeyService, @IConfigurationService configurationService: IConfigurationService, - @IDecorationsService decorationService: IDecorationsService + @IDecorationsService decorationService: IDecorationsService, + @IUriLabelService private uriLabelService: IUriLabelService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService, configurationService); @@ -147,7 +149,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView } public get name(): string { - return this.contextService.getWorkspace().name; + return this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace()); } public get title(): string { diff --git a/src/vs/workbench/parts/logs/electron-browser/logsActions.ts b/src/vs/workbench/parts/logs/electron-browser/logsActions.ts index e9695b3cde0..0920a329064 100644 --- a/src/vs/workbench/parts/logs/electron-browser/logsActions.ts +++ b/src/vs/workbench/parts/logs/electron-browser/logsActions.ts @@ -16,6 +16,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import URI from 'vs/base/common/uri'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; +import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; export class OpenLogsFolderAction extends Action { @@ -42,14 +43,16 @@ export class ShowLogsAction extends Action { constructor(id: string, label: string, @IQuickInputService private quickInputService: IQuickInputService, @IOutputService private outputService: IOutputService, - @IWorkspaceContextService private contextService: IWorkspaceContextService + @IWorkspaceContextService private contextService: IWorkspaceContextService, + @IUriLabelService private uriLabelService: IUriLabelService ) { super(id, label); } run(): TPromise { + const workspaceName = this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace()); const entries: IQuickPickItem[] = [ - { id: Constants.rendererLogChannelId, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") }, + { id: Constants.rendererLogChannelId, label: workspaceName ? nls.localize('rendererProcess', "Window ({0})", workspaceName) : nls.localize('emptyWindow', "Window") }, { id: Constants.extHostLogChannelId, label: nls.localize('extensionHost', "Extension Host") }, { id: Constants.sharedLogChannelId, label: nls.localize('sharedProcess', "Shared") }, { id: Constants.mainLogChannelId, label: nls.localize('mainProcess', "Main") } @@ -75,14 +78,16 @@ export class OpenLogFileAction extends Action { @IEnvironmentService private environmentService: IEnvironmentService, @ICommandService private commandService: ICommandService, @IWindowService private windowService: IWindowService, - @IWorkspaceContextService private contextService: IWorkspaceContextService + @IWorkspaceContextService private contextService: IWorkspaceContextService, + @IUriLabelService private uriLabelService: IUriLabelService ) { super(id, label); } run(): TPromise { + const workspaceName = this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace()); const entries: IQuickPickItem[] = [ - { id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") }, + { id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: workspaceName ? nls.localize('rendererProcess', "Window ({0})", workspaceName) : nls.localize('emptyWindow', "Window") }, { id: URI.file(paths.join(this.environmentService.logsPath, `exthost${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: nls.localize('extensionHost', "Extension Host") }, { id: URI.file(paths.join(this.environmentService.logsPath, `sharedprocess.log`)).fsPath, label: nls.localize('sharedProcess', "Shared") }, { id: URI.file(paths.join(this.environmentService.logsPath, `main.log`)).fsPath, label: nls.localize('mainProcess', "Main") }, @@ -142,4 +147,4 @@ export class SetLogLevelAction extends Action { } return void 0; } -} \ No newline at end of file +} 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 4ac216e7e23..82ef9f6b2fa 100644 --- a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts +++ b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts @@ -41,7 +41,7 @@ suite('QueryBuilder', () => { instantiationService.stub(IConfigurationService, mockConfigService); mockContextService = new TestContextService(); - mockWorkspace = new Workspace('workspace', 'workspace', toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }])); + mockWorkspace = new Workspace('workspace', toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }])); mockContextService.setWorkspace(mockWorkspace); instantiationService.stub(IWorkspaceContextService, mockContextService); diff --git a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts index 3af98297733..8148609ee53 100644 --- a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts +++ b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts @@ -39,7 +39,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', crypto.cre class TestBackupFileService extends BackupFileService { constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) { - const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }); + const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }); super(workspaceBackupPath, fileService); } diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index 340c8499127..2576c9e4cfc 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -41,7 +41,6 @@ import { UserConfiguration } from 'vs/platform/configuration/node/configuration' import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema'; import { localize } from 'vs/nls'; import { isEqual } from 'vs/base/common/resources'; -import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; export class WorkspaceService extends Disposable implements IWorkspaceConfigurationService, IWorkspaceContextService { @@ -72,7 +71,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat private configurationEditingService: ConfigurationEditingService; private jsonEditingService: JSONEditingService; - constructor(private environmentService: IEnvironmentService, private uriLabelService: IUriLabelService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) { + constructor(private environmentService: IEnvironmentService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) { super(); this.defaultConfiguration = new DefaultConfigurationModel(); @@ -341,8 +340,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat .then(() => { const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(workspaceConfigPath.fsPath))); const workspaceId = workspaceIdentifier.id; - const workspaceName = this.uriLabelService.getWorkspaceLabel({ id: workspaceId, configPath: workspaceConfigPath.fsPath }); - return new Workspace(workspaceId, workspaceName, workspaceFolders, workspaceConfigPath); + return new Workspace(workspaceId, workspaceFolders, workspaceConfigPath); }); } @@ -364,11 +362,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat } const id = createHash('md5').update(folder.fsPath).update(ctime ? String(ctime) : '').digest('hex'); - return new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime); + return new Workspace(id, toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime); }); } else { const id = createHash('md5').update(folder.toString()).digest('hex'); - return TPromise.as(new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ uri: folder.toString() }]), null)); + return TPromise.as(new Workspace(id, toWorkspaceFolders([{ uri: folder.toString() }]), null)); } } diff --git a/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts b/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts index ec8107bed48..b9fb772b270 100644 --- a/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts +++ b/src/vs/workbench/services/configuration/test/common/configurationModels.test.ts @@ -115,7 +115,7 @@ suite('WorkspaceConfigurationChangeEvent', () => { configurationChangeEvent.change(['window.restoreWindows'], URI.file('folder2')); configurationChangeEvent.telemetryData(ConfigurationTarget.WORKSPACE, {}); - let testObject = new WorkspaceConfigurationChangeEvent(configurationChangeEvent, new Workspace('id', 'name', + let testObject = new WorkspaceConfigurationChangeEvent(configurationChangeEvent, new Workspace('id', [new WorkspaceFolder({ index: 0, name: '1', uri: URI.file('folder1') }), new WorkspaceFolder({ index: 1, name: '2', uri: URI.file('folder2') }), new WorkspaceFolder({ index: 2, name: '3', uri: URI.file('folder3') })])); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts index f201f562127..a6ab72cead7 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts @@ -39,7 +39,6 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { ICommandService } from 'vs/platform/commands/common/commands'; import { CommandService } from 'vs/workbench/services/commands/common/commandService'; import URI from 'vs/base/common/uri'; -import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -103,7 +102,7 @@ suite('ConfigurationEditingService', () => { instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); instantiationService.stub(IEnvironmentService, environmentService); - const workspaceService = new WorkspaceService(environmentService, new UriLabelService(environmentService)); + const workspaceService = new WorkspaceService(environmentService); instantiationService.stub(IWorkspaceContextService, workspaceService); return workspaceService.initialize(noWorkspace ? {} as IWindowConfiguration : URI.file(workspaceDir)).then(() => { instantiationService.stub(IConfigurationService, workspaceService); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index d4bc36c32d6..64e9352f99a 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -35,7 +35,6 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/ import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; -import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -87,8 +86,7 @@ suite('WorkspaceContextService - Folder', () => { workspaceResource = folderDir; const globalSettingsFile = path.join(parentDir, 'settings.json'); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - const uriLabelService = new UriLabelService(environmentService); - workspaceContextService = new WorkspaceService(environmentService, uriLabelService); + workspaceContextService = new WorkspaceService(environmentService); return (workspaceContextService).initialize(URI.file(folderDir)); }); }); @@ -145,8 +143,7 @@ suite('WorkspaceContextService - Workspace', () => { parentResource = parentDir; const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); - const uriLabelService = new UriLabelService(environmentService); - const workspaceService = new WorkspaceService(environmentService, uriLabelService); + const workspaceService = new WorkspaceService(environmentService); const instantiationService = workbenchInstantiationService(); instantiationService.stub(IWorkspaceContextService, workspaceService); @@ -409,8 +406,7 @@ suite('WorkspaceService - Initialization', () => { const instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - const uriLabelService = new UriLabelService(environmentService); - const workspaceService = new WorkspaceService(environmentService, uriLabelService); + const workspaceService = new WorkspaceService(environmentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -665,8 +661,7 @@ suite('WorkspaceConfigurationService - Folder', () => { const instantiationService = workbenchInstantiationService(); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - const uriLabelService = new UriLabelService(environmentService); - const workspaceService = new WorkspaceService(environmentService, uriLabelService); + const workspaceService = new WorkspaceService(environmentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -941,8 +936,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { parentResource = parentDir; environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); - const uriLabelService = new UriLabelService(environmentService); - const workspaceService = new WorkspaceService(environmentService, uriLabelService); + const workspaceService = new WorkspaceService(environmentService); const instantiationService = workbenchInstantiationService(); instantiationService.stub(IWorkspaceContextService, workspaceService); diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts b/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts index 48e978387d3..d74d74631cc 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts @@ -23,7 +23,7 @@ import { IMessagePassingProtocol } from 'vs/base/parts/ipc/node/ipc'; import { generateRandomPipeName, Protocol } from 'vs/base/parts/ipc/node/ipc.net'; import { createServer, Server, Socket } from 'net'; import { Event, Emitter, debounceEvent, mapEvent, anyEvent, fromNodeEventEmitter } from 'vs/base/common/event'; -import { IInitData, IWorkspaceData, IConfigurationInitData } from 'vs/workbench/api/node/extHost.protocol'; +import { IInitData, IConfigurationInitData } from 'vs/workbench/api/node/extHost.protocol'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; import { ICrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService'; @@ -38,6 +38,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/ import { getPathFromAmdModule } from 'vs/base/common/amd'; import { timeout } from 'vs/base/common/async'; import { isMessageOfType, MessageType, createMessageOfType } from 'vs/workbench/common/extensionHostProtocol'; +import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel'; export interface IExtensionHostStarter { readonly onCrashed: Event<[number, string]>; @@ -81,7 +82,8 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter { @IWorkspaceConfigurationService private readonly _configurationService: IWorkspaceConfigurationService, @ITelemetryService private readonly _telemetryService: ITelemetryService, @ICrashReporterService private readonly _crashReporterService: ICrashReporterService, - @ILogService private readonly _logService: ILogService + @ILogService private readonly _logService: ILogService, + @IUriLabelService private readonly _uriLabelService: IUriLabelService ) { // handle extension host lifecycle a bit special when we know we are developing an extension that runs inside this._isExtensionDevHost = this._environmentService.isExtensionDevelopment; @@ -371,6 +373,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter { private _createExtHostInitData(): TPromise { return TPromise.join([this._telemetryService.getTelemetryInfo(), this._extensions]).then(([telemetryInfo, extensionDescriptions]) => { const configurationData: IConfigurationInitData = { ...this._configurationService.getConfigurationData(), configurationScopes: {} }; + const workspace = this._contextService.getWorkspace(); const r: IInitData = { parentPid: process.pid, environment: { @@ -380,7 +383,12 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter { extensionDevelopmentPath: this._environmentService.extensionDevelopmentPath, extensionTestsPath: this._environmentService.extensionTestsPath }, - workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace(), + workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : { + configuration: workspace.configuration, + folders: workspace.folders, + id: workspace.id, + name: this._uriLabelService.getWorkspaceLabel(workspace) + }, extensions: extensionDescriptions, // Send configurations scopes only in development mode. configuration: !this._environmentService.isBuilt || this._environmentService.isExtensionDevelopment ? { ...configurationData, configurationScopes: getScopes() } : configurationData, diff --git a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts index 6d834e52b6a..43e10816ddb 100644 --- a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts +++ b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts @@ -37,7 +37,7 @@ suite('FileService', () => { const sourceDir = getPathFromAmdModule(require, './fixtures/service'); return pfs.copy(sourceDir, testDir).then(() => { - service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }); + service = new FileService(new TestContextService(new Workspace(testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }); }); }); @@ -853,7 +853,7 @@ suite('FileService', () => { const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService); const _service = new FileService( - new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), + new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, textResourceConfigurationService, configurationService, @@ -898,7 +898,7 @@ suite('FileService', () => { const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService); const _service = new FileService( - new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), + new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, textResourceConfigurationService, configurationService, @@ -932,7 +932,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'index.html')); const _service = new FileService( - new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), + new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), diff --git a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts index 92fba70ec97..cb922f849d5 100644 --- a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts @@ -86,7 +86,7 @@ suite('KeybindingsEditing', () => { instantiationService.stub(ILogService, new TestLogService()); instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl)); instantiationService.stub(IFileService, new FileService( - new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), + new TestContextService(new Workspace(testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), diff --git a/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts b/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts index e524bcd9ef2..95113e157fe 100644 --- a/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/breadcrumbModel.test.ts @@ -16,7 +16,7 @@ import { FileKind } from 'vs/platform/files/common/files'; suite('Breadcrumb Model', function () { - const workspaceService = new TestContextService(new Workspace('ffff', 'Test', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })])); + const workspaceService = new TestContextService(new Workspace('ffff', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })])); const configService = new class extends TestConfigurationService { getValue(...args: any[]) { if (args[0] === 'breadcrumbs.filePath') { diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 0013574b689..19ef6688f08 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -21,7 +21,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; import { IModelService } from 'vs/editor/common/services/modelService'; import { EditOperation } from 'vs/editor/common/core/editOperation'; -import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices'; +import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; import { TPromise } from 'vs/base/common/winjs.base'; import { ResourceTextEdit } from 'vs/editor/common/modes'; import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService'; @@ -84,7 +84,7 @@ suite('MainThreadEditors', () => { } }; - const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService)); + const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService, new TestContextService())); const rpcProtocol = new TestRPCProtocol(); rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock() { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 16c593921a9..28b58ffa681 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -271,7 +271,7 @@ export function workbenchInstantiationService(): IInstantiationService { instantiationService.stub(IHashService, new TestHashService()); instantiationService.stub(ILogService, new TestLogService()); instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)])); - instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService)); + instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService, workspaceContextService)); const editorService = new TestEditorService(); instantiationService.stub(IEditorService, editorService); instantiationService.stub(ICodeEditorService, new TestCodeEditorService()); From 1b07ac78bae7b255e963751390b72a3c172588fe Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 23 Aug 2018 12:27:32 +0200 Subject: [PATCH 5/5] remove console.log --- src/vs/platform/uriLabel/common/uriLabel.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/platform/uriLabel/common/uriLabel.ts b/src/vs/platform/uriLabel/common/uriLabel.ts index f676d7582ea..1212469e636 100644 --- a/src/vs/platform/uriLabel/common/uriLabel.ts +++ b/src/vs/platform/uriLabel/common/uriLabel.ts @@ -109,7 +109,6 @@ export class UriLabelService implements IUriLabelService { } // Workspace: Saved - console.log(workspace.configPath); const filename = basename(workspace.configPath); const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1); if (options && options.verbose) {