Skip to content

Commit

Permalink
Correctly revert saveable on widget close (#14062)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Aug 22, 2024
1 parent 5af9da6 commit c3ffc5f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/browser/saveable-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c3ffc5f

Please sign in to comment.