提交 475cb9ea 编写于 作者: M Martin Aeschlimann

revive IWorkspaceIdentifier

上级 b5b21ead
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; 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 { 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 { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
...@@ -63,7 +63,7 @@ export class WindowsChannel implements IServerChannel { ...@@ -63,7 +63,7 @@ export class WindowsChannel implements IServerChannel {
case 'removeFromRecentlyOpened': { case 'removeFromRecentlyOpened': {
let paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string> = arg; let paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string> = arg;
if (Array.isArray(paths)) { 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); return this.service.removeFromRecentlyOpened(paths);
} }
...@@ -165,7 +165,9 @@ export class WindowsChannelClient implements IWindowsService { ...@@ -165,7 +165,9 @@ export class WindowsChannelClient implements IWindowsService {
} }
enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult> { enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult> {
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<void> { toggleFullScreen(windowId: number): Promise<void> {
...@@ -191,7 +193,7 @@ export class WindowsChannelClient implements IWindowsService { ...@@ -191,7 +193,7 @@ export class WindowsChannelClient implements IWindowsService {
getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> { getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
return this.channel.call('getRecentlyOpened', windowId) return this.channel.call('getRecentlyOpened', windowId)
.then((recentlyOpened: IRecentlyOpened) => { .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); recentlyOpened.files = recentlyOpened.files.map(URI.revive);
return recentlyOpened; return recentlyOpened;
}); });
...@@ -286,7 +288,17 @@ export class WindowsChannelClient implements IWindowsService { ...@@ -286,7 +288,17 @@ export class WindowsChannelClient implements IWindowsService {
} }
getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { 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<number> { getWindowCount(): Promise<number> {
......
...@@ -7,7 +7,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ...@@ -7,7 +7,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; 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<IWorkspacesMainService>('workspacesMainService'); export const IWorkspacesMainService = createDecorator<IWorkspacesMainService>('workspacesMainService');
export const IWorkspacesService = createDecorator<IWorkspacesService>('workspacesService'); export const IWorkspacesService = createDecorator<IWorkspacesService>('workspacesService');
...@@ -26,6 +26,10 @@ export interface IWorkspaceIdentifier { ...@@ -26,6 +26,10 @@ export interface IWorkspaceIdentifier {
configPath: URI; 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 { export function isStoredWorkspaceFolder(thing: any): thing is IStoredWorkspaceFolder {
return isRawFileWorkspaceFolder(thing) || isRawUriWorkspaceFolder(thing); return isRawFileWorkspaceFolder(thing) || isRawUriWorkspaceFolder(thing);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; 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 { URI } from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
...@@ -45,6 +45,6 @@ export class WorkspacesChannelClient implements IWorkspacesService { ...@@ -45,6 +45,6 @@ export class WorkspacesChannelClient implements IWorkspacesService {
constructor(private channel: IChannel) { } constructor(private channel: IChannel) { }
createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[]): Promise<IWorkspaceIdentifier> { createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[]): Promise<IWorkspaceIdentifier> {
return this.channel.call('createUntitledWorkspace', folders); return this.channel.call('createUntitledWorkspace', folders).then(reviveWorkspaceIdentifier);
} }
} }
...@@ -29,7 +29,7 @@ import { IUpdateService } from 'vs/platform/update/common/update'; ...@@ -29,7 +29,7 @@ import { IUpdateService } from 'vs/platform/update/common/update';
import { URLHandlerChannel, URLServiceChannelClient } from 'vs/platform/url/node/urlIpc'; import { URLHandlerChannel, URLServiceChannelClient } from 'vs/platform/url/node/urlIpc';
import { IURLService } from 'vs/platform/url/common/url'; import { IURLService } from 'vs/platform/url/common/url';
import { WorkspacesChannelClient } from 'vs/platform/workspaces/node/workspacesIpc'; 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 { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import * as fs from 'fs'; import * as fs from 'fs';
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log'; import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
...@@ -87,6 +87,9 @@ function revive(workbench: IWindowConfiguration) { ...@@ -87,6 +87,9 @@ function revive(workbench: IWindowConfiguration) {
if (workbench.folderUri) { if (workbench.folderUri) {
workbench.folderUri = uri.revive(workbench.folderUri); workbench.folderUri = uri.revive(workbench.folderUri);
} }
if (workbench.workspace) {
workbench.workspace = reviveWorkspaceIdentifier(workbench.workspace);
}
const filesToWaitPaths = workbench.filesToWait && workbench.filesToWait.paths; const filesToWaitPaths = workbench.filesToWait && workbench.filesToWait.paths;
[filesToWaitPaths, workbench.filesToOpen, workbench.filesToCreate, workbench.filesToDiff].forEach(paths => { [filesToWaitPaths, workbench.filesToOpen, workbench.filesToCreate, workbench.filesToDiff].forEach(paths => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册