diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index c80709d5e91..df64227750e 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -37,6 +37,7 @@ export interface IWindowsService { unmaximizeWindow(windowId: number): TPromise; setDocumentEdited(windowId: number, flag: boolean): TPromise; quit(): TPromise; + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise; // Global methods openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise; @@ -95,4 +96,4 @@ export interface IWindowSettings { autoDetectHighContrast: boolean; menuBarVisibility: MenuBarVisibility; newWindowDimensions: 'default' | 'inherit' | 'maximized' | 'fullscreen'; -} \ No newline at end of file +} diff --git a/src/vs/platform/windows/common/windowsIpc.ts b/src/vs/platform/windows/common/windowsIpc.ts index ab94cf41709..45665b734f2 100644 --- a/src/vs/platform/windows/common/windowsIpc.ts +++ b/src/vs/platform/windows/common/windowsIpc.ts @@ -80,6 +80,7 @@ export class WindowsChannel implements IWindowsChannel { case 'showWindow': return this.service.showWindow(arg); case 'getWindows': return this.service.getWindows(); case 'getWindowCount': return this.service.getWindowCount(); + case 'relaunch': return this.service.relaunch(arg[0]); case 'quit': return this.service.quit(); case 'log': return this.service.log(arg[0], arg[1]); case 'closeExtensionHostWindow': return this.service.closeExtensionHostWindow(arg); @@ -175,6 +176,10 @@ export class WindowsChannelClient implements IWindowsService { return this.channel.call('quit'); } + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + return this.channel.call('relaunch', [options]); + } + openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise { return this.channel.call('openWindow', [paths, options]); } diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index a5924f65105..3727fd66516 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -264,6 +264,24 @@ export class WindowsService implements IWindowsService, IDisposable { return TPromise.as(null); } + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + const args = process.argv.slice(1); + if (options.addArgs) { + args.push(...options.addArgs); + } + if (options.removeArgs) { + for (const a of options.removeArgs) { + const idx = args.indexOf(a); + if (idx >= 0) { + args.splice(idx, 1); + } + } + } + app.quit(); + app.once('quit', () => app.relaunch({ args })); + return TPromise.as(null); + } + private openFileForURI(filePath: string): TPromise { const cli = assign(Object.create(null), this.environmentService.args, { goto: true }); const pathsToOpen = [filePath]; diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 95fa8521883..47b92497eac 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -917,6 +917,10 @@ export class TestWindowsService implements IWindowsService { return TPromise.as(void 0); } + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + return TPromise.as(void 0); + } + // Global methods openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise { return TPromise.as(void 0);