save participants do not run on shutdown

This commit is contained in:
Benjamin Pasero
2016-09-22 16:29:46 +02:00
parent 6fc7710985
commit 1d7279888f
4 changed files with 24 additions and 1 deletions

View File

@@ -20,6 +20,8 @@ export class LifecycleService implements ILifecycleService {
private _onWillShutdown = new Emitter<ShutdownEvent>();
private _onShutdown = new Emitter<void>();
private _willShutdown: boolean;
constructor(
@IMessageService private messageService: IMessageService,
@IWindowService private windowService: IWindowService
@@ -27,6 +29,10 @@ export class LifecycleService implements ILifecycleService {
this.registerListeners();
}
public get willShutdown(): boolean {
return this._willShutdown;
}
public get onWillShutdown(): Event<ShutdownEvent> {
return this._onWillShutdown.event;
}
@@ -40,8 +46,12 @@ export class LifecycleService implements ILifecycleService {
// Main side indicates that window is about to unload, check for vetos
ipc.on('vscode:beforeUnload', (event, reply: { okChannel: string, cancelChannel: string }) => {
this._willShutdown = true;
// trigger onWillShutdown events and veto collecting
this.onBeforeUnload().done(veto => {
if (veto) {
this._willShutdown = false; // reset this flag since the shutdown has been vetoed!
ipc.send(reply.cancelChannel, windowId);
} else {
this._onShutdown.fire();