diff --git a/src/vs/platform/windows/node/windowsIpc.ts b/src/vs/platform/windows/node/windowsIpc.ts index dc10702ca5bdc2e1def9905ec03c8d6df1812849..408b73805177d3dc013cc30dafc2f5272fff24d0 100644 --- a/src/vs/platform/windows/node/windowsIpc.ts +++ b/src/vs/platform/windows/node/windowsIpc.ts @@ -6,7 +6,7 @@ import { Event } from 'vs/base/common/event'; import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows'; -import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; import { URI } from 'vs/base/common/uri'; @@ -63,7 +63,7 @@ export class WindowsChannel implements IServerChannel { case 'removeFromRecentlyOpened': { let paths: Array = arg; if (Array.isArray(paths)) { - paths = paths.map(path => isWorkspaceIdentifier(path) || typeof path === 'string' ? path : URI.revive(path)); + paths = paths.map(path => isWorkspaceIdentifier(path) ? reviveWorkspaceIdentifier(path) : typeof path === 'string' ? path : URI.revive(path)); } return this.service.removeFromRecentlyOpened(paths); } @@ -165,7 +165,9 @@ export class WindowsChannelClient implements IWindowsService { } enterWorkspace(windowId: number, path: URI): Promise { - return this.channel.call('enterWorkspace', [windowId, path]); + return this.channel.call('enterWorkspace', [windowId, path]).then((result: IEnterWorkspaceResult) => { + return { backupPath: result.backupPath, workspace: reviveWorkspaceIdentifier(result.workspace) }; + }); } toggleFullScreen(windowId: number): Promise { @@ -191,7 +193,7 @@ export class WindowsChannelClient implements IWindowsService { getRecentlyOpened(windowId: number): Promise { return this.channel.call('getRecentlyOpened', windowId) .then((recentlyOpened: IRecentlyOpened) => { - recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace)); + recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? reviveWorkspaceIdentifier(workspace) : URI.revive(workspace)); recentlyOpened.files = recentlyOpened.files.map(URI.revive); return recentlyOpened; }); @@ -286,7 +288,17 @@ export class WindowsChannelClient implements IWindowsService { } getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { - return this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; }); + return this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { + for (const win of result) { + if (win.folderUri) { + win.folderUri = URI.revive(win.folderUri); + } + if (win.workspace) { + win.workspace = reviveWorkspaceIdentifier(win.workspace); + } + } + return result; + }); } getWindowCount(): Promise { diff --git a/src/vs/platform/workspaces/common/workspaces.ts b/src/vs/platform/workspaces/common/workspaces.ts index a5b8c5a57b8d68b93f8339c1926a4f8a786e4cd6..0b4c63729544e72ab281156bf3740f551006af89 100644 --- a/src/vs/platform/workspaces/common/workspaces.ts +++ b/src/vs/platform/workspaces/common/workspaces.ts @@ -7,7 +7,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { localize } from 'vs/nls'; import { Event } from 'vs/base/common/event'; import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; -import { URI } from 'vs/base/common/uri'; +import { URI, UriComponents } from 'vs/base/common/uri'; export const IWorkspacesMainService = createDecorator('workspacesMainService'); export const IWorkspacesService = createDecorator('workspacesService'); @@ -26,6 +26,10 @@ export interface IWorkspaceIdentifier { configPath: URI; } +export function reviveWorkspaceIdentifier(workspace: { id: string, configPath: UriComponents; }) { + return { id: workspace.id, configPath: URI.revive(workspace.configPath) }; +} + export function isStoredWorkspaceFolder(thing: any): thing is IStoredWorkspaceFolder { return isRawFileWorkspaceFolder(thing) || isRawUriWorkspaceFolder(thing); } diff --git a/src/vs/platform/workspaces/node/workspacesIpc.ts b/src/vs/platform/workspaces/node/workspacesIpc.ts index 6b44c1dedead58c8bf46b663fa47341c2082cd17..11ae4da17ec89c8e6d43da3f35506196e65f0f2b 100644 --- a/src/vs/platform/workspaces/node/workspacesIpc.ts +++ b/src/vs/platform/workspaces/node/workspacesIpc.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; -import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; @@ -45,6 +45,6 @@ export class WorkspacesChannelClient implements IWorkspacesService { constructor(private channel: IChannel) { } createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[]): Promise { - return this.channel.call('createUntitledWorkspace', folders); + return this.channel.call('createUntitledWorkspace', folders).then(reviveWorkspaceIdentifier); } } diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 1e6333c73140137e6d0a10efcbe7356bad18fd4c..07a0e5022d3d41cd377f0d648c71bcd5948a0664 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -29,7 +29,7 @@ import { IUpdateService } from 'vs/platform/update/common/update'; import { URLHandlerChannel, URLServiceChannelClient } from 'vs/platform/url/node/urlIpc'; import { IURLService } from 'vs/platform/url/common/url'; import { WorkspacesChannelClient } from 'vs/platform/workspaces/node/workspacesIpc'; -import { IWorkspacesService, ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, IMultiFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspacesService, ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, IMultiFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { createSpdLogService } from 'vs/platform/log/node/spdlogService'; import * as fs from 'fs'; import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log'; @@ -87,6 +87,9 @@ function revive(workbench: IWindowConfiguration) { if (workbench.folderUri) { workbench.folderUri = uri.revive(workbench.folderUri); } + if (workbench.workspace) { + workbench.workspace = reviveWorkspaceIdentifier(workbench.workspace); + } const filesToWaitPaths = workbench.filesToWait && workbench.filesToWait.paths; [filesToWaitPaths, workbench.filesToOpen, workbench.filesToCreate, workbench.filesToDiff].forEach(paths => {