提交 a8d47748 编写于 作者: J Johannes Rieken

add IWindowService#relaunch

上级 68d37dac
......@@ -37,6 +37,7 @@ export interface IWindowsService {
unmaximizeWindow(windowId: number): TPromise<void>;
setDocumentEdited(windowId: number, flag: boolean): TPromise<void>;
quit(): TPromise<void>;
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void>;
// Global methods
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void>;
......
......@@ -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<void> {
return this.channel.call('relaunch', [options]);
}
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void> {
return this.channel.call('openWindow', [paths, options]);
}
......
......@@ -264,6 +264,24 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
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<void> {
const cli = assign(Object.create(null), this.environmentService.args, { goto: true });
const pathsToOpen = [filePath];
......
......@@ -917,6 +917,10 @@ export class TestWindowsService implements IWindowsService {
return TPromise.as(void 0);
}
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
return TPromise.as(void 0);
}
// Global methods
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void> {
return TPromise.as(void 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册