From 5682c8ffb1f8049ccbf7626fefc9ff961efb5367 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 29 Sep 2016 08:49:44 +0200 Subject: [PATCH] fix #12979 --- .../common/editor/untitledEditorModel.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/common/editor/untitledEditorModel.ts b/src/vs/workbench/common/editor/untitledEditorModel.ts index b0a573577bd..c3f5c3cb1d1 100644 --- a/src/vs/workbench/common/editor/untitledEditorModel.ts +++ b/src/vs/workbench/common/editor/untitledEditorModel.ts @@ -140,16 +140,18 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS private onModelContentChanged(): void { - // turn dirty if we were not - if (!this.dirty) { - this.dirty = true; - this._onDidChangeDirty.fire(); + // mark the untitled editor as non-dirty once its content becomes empty and we do + // not have an associated path set. we never want dirty indicator in that case. + if (!this.hasAssociatedFilePath && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') { + if (this.dirty) { + this.dirty = false; + this._onDidChangeDirty.fire(); + } } - // mark the untitled editor as non-dirty once its content becomes empty and we do - // not have an associated path set - else if (!this.hasAssociatedFilePath && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') { - this.dirty = false; + // turn dirty if we were not + else if (!this.dirty) { + this.dirty = true; this._onDidChangeDirty.fire(); } }