From 5cbb4f19d65058f3875fb303ac0ee86a35140491 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 25 Mar 2019 14:22:12 +0000 Subject: [PATCH] [shell] fix #4697: reset prevent close on keyup and beforeunload Signed-off-by: Anton Kosyakov --- .../src/browser/common-frontend-contribution.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index 296db2f311f90..9c3510ce9bb87 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -599,16 +599,18 @@ export class CommonFrontendContribution implements FrontendApplicationContributi this.shouldPreventClose = isCtrlCmd(event) || event.code === 'KeyW'; }); - window.document.addEventListener('keyup', event => { - if (isCtrlCmd(event) || event.code === 'KeyW') { - this.shouldPreventClose = false; - } + window.document.addEventListener('keyup', () => { + this.shouldPreventClose = false; }); } onWillStop() { - if (this.shouldPreventClose || this.shell.canSaveAll()) { - return true; + try { + if (this.shouldPreventClose || this.shell.canSaveAll()) { + return true; + } + } finally { + this.shouldPreventClose = false; } } }