From c3ffc5fa81879943e3b3ad3caec3738ed2d0e5f9 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Thu, 22 Aug 2024 17:12:02 +0200 Subject: [PATCH] Correctly revert saveable on widget close (#14062) --- 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();