@@ -61,6 +61,8 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
6161 }
6262
6363 private dirty = false ;
64+ private ignoreDirtyOnModelContentChange = false ;
65+
6466 private versionId = 0 ;
6567 private configuredEncoding : string | undefined ;
6668
@@ -130,6 +132,18 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
130132 }
131133 }
132134
135+ setValue ( value : string , ignoreDirty ?: boolean ) : void {
136+ if ( ignoreDirty ) {
137+ this . ignoreDirtyOnModelContentChange = true ;
138+ }
139+
140+ try {
141+ this . updateTextEditorModel ( createTextBufferFactory ( value ) ) ;
142+ } finally {
143+ this . ignoreDirtyOnModelContentChange = false ;
144+ }
145+ }
146+
133147 isReadonly ( ) : boolean {
134148 return false ;
135149 }
@@ -218,15 +232,17 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
218232 private onModelContentChanged ( model : ITextModel , e : IModelContentChangedEvent ) : void {
219233 this . versionId ++ ;
220234
221- // mark the untitled text editor as non-dirty once its content becomes empty and we do
222- // not have an associated path set. we never want dirty indicator in that case.
223- if ( ! this . hasAssociatedFilePath && model . getLineCount ( ) === 1 && model . getLineContent ( 1 ) === '' ) {
224- this . setDirty ( false ) ;
225- }
235+ if ( ! this . ignoreDirtyOnModelContentChange ) {
236+ // mark the untitled text editor as non-dirty once its content becomes empty and we do
237+ // not have an associated path set. we never want dirty indicator in that case.
238+ if ( ! this . hasAssociatedFilePath && model . getLineCount ( ) === 1 && model . getLineContent ( 1 ) === '' ) {
239+ this . setDirty ( false ) ;
240+ }
226241
227- // turn dirty otherwise
228- else {
229- this . setDirty ( true ) ;
242+ // turn dirty otherwise
243+ else {
244+ this . setDirty ( true ) ;
245+ }
230246 }
231247
232248 // Check for name change if first line changed in the range of 0-FIRST_LINE_NAME_MAX_LENGTH columns
0 commit comments