Skip to content

Commit 475cb9e

Browse files
committed
revive IWorkspaceIdentifier
1 parent b5b21ea commit 475cb9e

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

src/vs/platform/windows/node/windowsIpc.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Event } from 'vs/base/common/event';
77
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
88
import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows';
9-
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
9+
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
1010
import { IRecentlyOpened } from 'vs/platform/history/common/history';
1111
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
1212
import { URI } from 'vs/base/common/uri';
@@ -63,7 +63,7 @@ export class WindowsChannel implements IServerChannel {
6363
case 'removeFromRecentlyOpened': {
6464
let paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string> = arg;
6565
if (Array.isArray(paths)) {
66-
paths = paths.map(path => isWorkspaceIdentifier(path) || typeof path === 'string' ? path : URI.revive(path));
66+
paths = paths.map(path => isWorkspaceIdentifier(path) ? reviveWorkspaceIdentifier(path) : typeof path === 'string' ? path : URI.revive(path));
6767
}
6868
return this.service.removeFromRecentlyOpened(paths);
6969
}
@@ -165,7 +165,9 @@ export class WindowsChannelClient implements IWindowsService {
165165
}
166166

167167
enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult> {
168-
return this.channel.call('enterWorkspace', [windowId, path]);
168+
return this.channel.call('enterWorkspace', [windowId, path]).then((result: IEnterWorkspaceResult) => {
169+
return { backupPath: result.backupPath, workspace: reviveWorkspaceIdentifier(result.workspace) };
170+
});
169171
}
170172

171173
toggleFullScreen(windowId: number): Promise<void> {
@@ -191,7 +193,7 @@ export class WindowsChannelClient implements IWindowsService {
191193
getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
192194
return this.channel.call('getRecentlyOpened', windowId)
193195
.then((recentlyOpened: IRecentlyOpened) => {
194-
recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace));
196+
recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? reviveWorkspaceIdentifier(workspace) : URI.revive(workspace));
195197
recentlyOpened.files = recentlyOpened.files.map(URI.revive);
196198
return recentlyOpened;
197199
});
@@ -286,7 +288,17 @@ export class WindowsChannelClient implements IWindowsService {
286288
}
287289

288290
getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
289-
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; });
291+
return this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => {
292+
for (const win of result) {
293+
if (win.folderUri) {
294+
win.folderUri = URI.revive(win.folderUri);
295+
}
296+
if (win.workspace) {
297+
win.workspace = reviveWorkspaceIdentifier(win.workspace);
298+
}
299+
}
300+
return result;
301+
});
290302
}
291303

292304
getWindowCount(): Promise<number> {

src/vs/platform/workspaces/common/workspaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
77
import { localize } from 'vs/nls';
88
import { Event } from 'vs/base/common/event';
99
import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace';
10-
import { URI } from 'vs/base/common/uri';
10+
import { URI, UriComponents } from 'vs/base/common/uri';
1111

1212
export const IWorkspacesMainService = createDecorator<IWorkspacesMainService>('workspacesMainService');
1313
export const IWorkspacesService = createDecorator<IWorkspacesService>('workspacesService');
@@ -26,6 +26,10 @@ export interface IWorkspaceIdentifier {
2626
configPath: URI;
2727
}
2828

29+
export function reviveWorkspaceIdentifier(workspace: { id: string, configPath: UriComponents; }) {
30+
return { id: workspace.id, configPath: URI.revive(workspace.configPath) };
31+
}
32+
2933
export function isStoredWorkspaceFolder(thing: any): thing is IStoredWorkspaceFolder {
3034
return isRawFileWorkspaceFolder(thing) || isRawUriWorkspaceFolder(thing);
3135
}

src/vs/platform/workspaces/node/workspacesIpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
7-
import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces';
7+
import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
88
import { URI } from 'vs/base/common/uri';
99
import { Event } from 'vs/base/common/event';
1010

@@ -45,6 +45,6 @@ export class WorkspacesChannelClient implements IWorkspacesService {
4545
constructor(private channel: IChannel) { }
4646

4747
createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[]): Promise<IWorkspaceIdentifier> {
48-
return this.channel.call('createUntitledWorkspace', folders);
48+
return this.channel.call('createUntitledWorkspace', folders).then(reviveWorkspaceIdentifier);
4949
}
5050
}

src/vs/workbench/electron-browser/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { IUpdateService } from 'vs/platform/update/common/update';
2929
import { URLHandlerChannel, URLServiceChannelClient } from 'vs/platform/url/node/urlIpc';
3030
import { IURLService } from 'vs/platform/url/common/url';
3131
import { WorkspacesChannelClient } from 'vs/platform/workspaces/node/workspacesIpc';
32-
import { IWorkspacesService, ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, IMultiFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces';
32+
import { IWorkspacesService, ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, IMultiFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
3333
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
3434
import * as fs from 'fs';
3535
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
@@ -87,6 +87,9 @@ function revive(workbench: IWindowConfiguration) {
8787
if (workbench.folderUri) {
8888
workbench.folderUri = uri.revive(workbench.folderUri);
8989
}
90+
if (workbench.workspace) {
91+
workbench.workspace = reviveWorkspaceIdentifier(workbench.workspace);
92+
}
9093

9194
const filesToWaitPaths = workbench.filesToWait && workbench.filesToWait.paths;
9295
[filesToWaitPaths, workbench.filesToOpen, workbench.filesToCreate, workbench.filesToDiff].forEach(paths => {

0 commit comments

Comments
 (0)