mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 07:15:54 +01:00
towards better quit handling (for #22138)
This commit is contained in:
@@ -47,10 +47,15 @@ export interface ILifecycleService {
|
||||
|
||||
ready(): void;
|
||||
registerWindow(vscodeWindow: VSCodeWindow): void;
|
||||
|
||||
unload(vscodeWindow: VSCodeWindow, reason: UnloadReason): TPromise<boolean /* veto */>;
|
||||
|
||||
relaunch(options?: { addArgs?: string[], removeArgs?: string[] });
|
||||
|
||||
quit(fromUpdate?: boolean): TPromise<boolean /* veto */>;
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] });
|
||||
isQuitRequested(): boolean;
|
||||
|
||||
kill(code?: number);
|
||||
}
|
||||
|
||||
export class LifecycleService implements ILifecycleService {
|
||||
@@ -210,6 +215,7 @@ export class LifecycleService implements ILifecycleService {
|
||||
if (fromUpdate) {
|
||||
this.storageService.setItem(LifecycleService.QUIT_FROM_RESTART_MARKER, true);
|
||||
}
|
||||
|
||||
this.pendingQuitPromiseComplete(false /* no veto */);
|
||||
this.pendingQuitPromiseComplete = null;
|
||||
this.pendingQuitPromise = null;
|
||||
@@ -223,6 +229,10 @@ export class LifecycleService implements ILifecycleService {
|
||||
return this.pendingQuitPromise;
|
||||
}
|
||||
|
||||
public kill(code?: number): void {
|
||||
app.exit(code);
|
||||
}
|
||||
|
||||
public relaunch(options?: { addArgs?: string[], removeArgs?: string[] }): void {
|
||||
const args = process.argv.slice(1);
|
||||
if (options && options.addArgs) {
|
||||
@@ -238,10 +248,17 @@ export class LifecycleService implements ILifecycleService {
|
||||
}
|
||||
}
|
||||
|
||||
this.storageService.setItem(LifecycleService.QUIT_FROM_RESTART_MARKER, true);
|
||||
let vetod = false;
|
||||
app.once('quit', () => {
|
||||
if (!vetod) {
|
||||
this.storageService.setItem(LifecycleService.QUIT_FROM_RESTART_MARKER, true);
|
||||
app.relaunch({ args });
|
||||
}
|
||||
});
|
||||
|
||||
app.quit();
|
||||
app.once('quit', () => app.relaunch({ args }));
|
||||
this.quit().then(veto => {
|
||||
vetod = veto;
|
||||
});
|
||||
}
|
||||
|
||||
public isQuitRequested(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user