add IWindowService#relaunch
This commit is contained in:
parent
68d37dac12
commit
a8d477482e
|
@ -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>;
|
||||
|
@ -95,4 +96,4 @@ export interface IWindowSettings {
|
|||
autoDetectHighContrast: boolean;
|
||||
menuBarVisibility: MenuBarVisibility;
|
||||
newWindowDimensions: 'default' | 'inherit' | 'maximized' | 'fullscreen';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue