@@ -61,6 +61,8 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
61
61
}
62
62
63
63
private dirty = false ;
64
+ private ignoreDirtyOnModelContentChange = false ;
65
+
64
66
private versionId = 0 ;
65
67
private configuredEncoding : string | undefined ;
66
68
@@ -130,6 +132,18 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
130
132
}
131
133
}
132
134
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
+
133
147
isReadonly ( ) : boolean {
134
148
return false ;
135
149
}
@@ -218,15 +232,17 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
218
232
private onModelContentChanged ( model : ITextModel , e : IModelContentChangedEvent ) : void {
219
233
this . versionId ++ ;
220
234
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
+ }
226
241
227
- // turn dirty otherwise
228
- else {
229
- this . setDirty ( true ) ;
242
+ // turn dirty otherwise
243
+ else {
244
+ this . setDirty ( true ) ;
245
+ }
230
246
}
231
247
232
248
// Check for name change if first line changed in the range of 0-FIRST_LINE_NAME_MAX_LENGTH columns
0 commit comments