From d90f41e176df2089019956d9594e20099fe82e57 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Wed, 21 Aug 2024 12:38:27 +0200 Subject: [PATCH] Correctly revert saveable on widget close --- packages/core/src/browser/saveable-service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/browser/saveable-service.ts b/packages/core/src/browser/saveable-service.ts index 12b273019885a..15fbf85fe3c1d 100644 --- a/packages/core/src/browser/saveable-service.ts +++ b/packages/core/src/browser/saveable-service.ts @@ -174,7 +174,10 @@ export class SaveableService implements FrontendApplicationContribution { setDirty(saveableWidget, saveable.dirty); saveable.onDirtyChanged(() => setDirty(saveableWidget, saveable.dirty)); const closeWithSaving = this.createCloseWithSaving(); - const closeWithoutSaving = () => this.closeWithoutSaving(saveableWidget, false); + const closeWithoutSaving = async () => { + const revert = Saveable.closingWidgetWouldLoseSaveable(saveableWidget, Array.from(this.saveThrottles.keys())); + await this.closeWithoutSaving(saveableWidget, revert); + }; Object.assign(saveableWidget, { closeWithoutSaving, closeWithSaving, @@ -224,7 +227,8 @@ export class SaveableService implements FrontendApplicationContribution { } const notLastWithDocument = !Saveable.closingWidgetWouldLoseSaveable(widget, Array.from(this.saveThrottles.keys())); if (notLastWithDocument) { - return widget.closeWithoutSaving(false).then(() => undefined); + await widget.closeWithoutSaving(false); + return undefined; } if (options && options.shouldSave) { return options.shouldSave();