From 2996b94e3cdaefc4558ba4fa20224ef3a007729b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 29 Jan 2018 17:54:48 +0100 Subject: [PATCH] allow to close dirty editors when auto save is on --- src/vs/workbench/browser/parts/editor/editorPart.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index b477666f086..085f10d2e41 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -957,6 +957,16 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService // Switch to editor that we want to handle return this.openEditor(identifier.editor, null, this.stacks.positionOfGroup(identifier.group)).then(() => { return editor.confirmSave().then(res => { + + // It could be that the editor saved meanwhile, so we check again + // to see if anything needs to happen before closing for good. + // This can happen for example if autoSave: onFocusChange is configured + // so that the save happens when the dialog opens. + if (!editor.isDirty()) { + return res === ConfirmResult.CANCEL ? true : false; + } + + // Otherwise, handle accordingly switch (res) { case ConfirmResult.SAVE: return editor.save().then(ok => !ok);