From c205cfb0e71e2b7ea9f175682f8d4b1dc5053715 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 10 Aug 2020 12:39:36 +0000 Subject: [PATCH] [monaco] don't open dirty editor if auto save is enabled Signed-off-by: Anton Kosyakov --- packages/monaco/src/browser/monaco-workspace.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/monaco/src/browser/monaco-workspace.ts b/packages/monaco/src/browser/monaco-workspace.ts index 50c978841e26f..5a9690174f31f 100644 --- a/packages/monaco/src/browser/monaco-workspace.ts +++ b/packages/monaco/src/browser/monaco-workspace.ts @@ -218,9 +218,12 @@ export class MonacoWorkspace { // create a new reference to make sure the model is not disposed before it is // acquired by the editor, thus losing the changes that made it dirty. this.textModelService.createModelReference(model.textEditorModel.uri).then(ref => { - this.editorManager.open(new URI(model.uri), { - mode: 'open', - }).then(editor => ref.dispose()); + ( + model.autoSave === 'on' ? new Promise(resolve => model.onDidSaveModel(resolve)) : + this.editorManager.open(new URI(model.uri), { mode: 'open' }) + ).then( + () => ref.dispose() + ); }); } }