Skip to content

Commit

Permalink
fix: file-saving dialog with dirty editors (#12864)
Browse files Browse the repository at this point in the history
This commit fixes the issue where cancelling the file-saving dialog
incorrectly closes the editor.

Signed-off-by: Vlad Arama <[email protected]>
  • Loading branch information
vladarama authored Oct 26, 2023
1 parent 39935ec commit d2a2bb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/api-tests/src/saveable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Saveable', function () {
shouldSave: () => true
});
assert.isTrue(outOfSync, 'file should be out of sync');
assert.isTrue(widget.isDisposed, 'model should be disposed after close');
assert.isFalse(widget.isDisposed, 'model should not be disposed after close when we reject the save');
const state = await fileService.read(fileUri);
assert.equal(state.value, 'foo2', 'fs should NOT be updated');
});
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/browser/saveable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ export namespace Saveable {
if (typeof result === 'boolean') {
if (result) {
await (doSave?.(this) ?? Saveable.save(this));
if (!isDirty(this)) {
await this.closeWithoutSaving();
}
} else {
await this.closeWithoutSaving();
}
await this.closeWithoutSaving();
}
} finally {
closing = false;
Expand Down

0 comments on commit d2a2bb6

Please sign in to comment.