@@ -20,7 +20,7 @@ import { ITextResourceConfigurationChangeEvent, ITextResourceConfigurationServic
20
20
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
21
21
import { IThemeService } from 'vs/platform/theme/common/themeService' ;
22
22
import { TextFileOperationError , TextFileOperationResult } from 'vs/workbench/services/textfile/common/textfiles' ;
23
- import { ScrollType , IDiffEditorViewState , IDiffEditorModel } from 'vs/editor/common/editorCommon' ;
23
+ import { ScrollType , IDiffEditorViewState , IDiffEditorModel , IDiffEditorViewModel } from 'vs/editor/common/editorCommon' ;
24
24
import { Registry } from 'vs/platform/registry/common/platform' ;
25
25
import { URI } from 'vs/base/common/uri' ;
26
26
import { IEditorGroup , IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
@@ -91,7 +91,13 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
91
91
return this . diffEditorControl ?. getModifiedEditor ( ) ;
92
92
}
93
93
94
+ private _previousViewModel : IDiffEditorViewModel | null = null ;
95
+
94
96
override async setInput ( input : DiffEditorInput , options : ITextEditorOptions | undefined , context : IEditorOpenContext , token : CancellationToken ) : Promise < void > {
97
+ if ( this . _previousViewModel ) {
98
+ this . _previousViewModel . dispose ( ) ;
99
+ this . _previousViewModel = null ;
100
+ }
95
101
96
102
// Cleanup previous things associated with the input
97
103
this . inputLifecycleStopWatch = undefined ;
@@ -118,6 +124,7 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
118
124
const resolvedDiffEditorModel = resolvedModel as TextDiffEditorModel ;
119
125
120
126
const vm = resolvedDiffEditorModel . textDiffEditorModel ? control . createViewModel ( resolvedDiffEditorModel . textDiffEditorModel ) : null ;
127
+ this . _previousViewModel = vm ;
121
128
await vm ?. waitForDiff ( ) ;
122
129
control . setModel ( vm ) ;
123
130
@@ -300,6 +307,11 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
300
307
}
301
308
302
309
override clearInput ( ) : void {
310
+ if ( this . _previousViewModel ) {
311
+ this . _previousViewModel . dispose ( ) ;
312
+ this . _previousViewModel = null ;
313
+ }
314
+
303
315
super . clearInput ( ) ;
304
316
305
317
// Log input lifecycle telemetry
0 commit comments