@@ -15,6 +15,7 @@ import { generateUuid } from '../../../../../../base/common/uuid.js';
15
15
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js' ;
16
16
import { ILanguageService } from '../../../../../../editor/common/languages/language.js' ;
17
17
import { IModelService } from '../../../../../../editor/common/services/model.js' ;
18
+ import { ITextModelService } from '../../../../../../editor/common/services/resolverService.js' ;
18
19
import { localize } from '../../../../../../nls.js' ;
19
20
import { ConfigurationTarget , IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js' ;
20
21
import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js' ;
@@ -69,6 +70,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
69
70
@IContextKeyService private readonly contextKeyService : IContextKeyService ,
70
71
@IChatWidgetService private readonly chatWidgetService : IChatWidgetService ,
71
72
@IPreferencesService private readonly preferencesService : IPreferencesService ,
73
+ @ITextModelService textModelService : ITextModelService ,
72
74
) {
73
75
super ( toolInvocation ) ;
74
76
@@ -115,12 +117,19 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
115
117
}
116
118
} ;
117
119
const langId = this . languageService . getLanguageIdByLanguageName ( terminalData . language ?? 'sh' ) ?? 'shellscript' ;
118
- const model = this . modelService . createModel (
120
+ const model = this . _register ( this . modelService . createModel (
119
121
terminalData . commandLine . toolEdited ?? terminalData . commandLine . original ,
120
122
this . languageService . createById ( langId ) ,
121
123
this . _getUniqueCodeBlockUri ( ) ,
122
124
true
123
- ) ;
125
+ ) ) ;
126
+ textModelService . createModelReference ( model . uri ) . then ( ref => {
127
+ if ( this . _store . isDisposed ) {
128
+ ref . dispose ( ) ;
129
+ } else {
130
+ this . _register ( ref ) ;
131
+ }
132
+ } ) ;
124
133
const editor = this . _register ( this . editorPool . get ( ) ) ;
125
134
const renderPromise = editor . object . render ( {
126
135
codeBlockIndex : this . codeBlockStartIndex ,
0 commit comments