@@ -15,6 +15,7 @@ import { generateUuid } from '../../../../../../base/common/uuid.js';
1515import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js' ;
1616import { ILanguageService } from '../../../../../../editor/common/languages/language.js' ;
1717import { IModelService } from '../../../../../../editor/common/services/model.js' ;
18+ import { ITextModelService } from '../../../../../../editor/common/services/resolverService.js' ;
1819import { localize } from '../../../../../../nls.js' ;
1920import { ConfigurationTarget , IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js' ;
2021import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js' ;
@@ -69,6 +70,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
6970 @IContextKeyService private readonly contextKeyService : IContextKeyService ,
7071 @IChatWidgetService private readonly chatWidgetService : IChatWidgetService ,
7172 @IPreferencesService private readonly preferencesService : IPreferencesService ,
73+ @ITextModelService textModelService : ITextModelService ,
7274 ) {
7375 super ( toolInvocation ) ;
7476
@@ -115,12 +117,19 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
115117 }
116118 } ;
117119 const langId = this . languageService . getLanguageIdByLanguageName ( terminalData . language ?? 'sh' ) ?? 'shellscript' ;
118- const model = this . modelService . createModel (
120+ const model = this . _register ( this . modelService . createModel (
119121 terminalData . commandLine . toolEdited ?? terminalData . commandLine . original ,
120122 this . languageService . createById ( langId ) ,
121123 this . _getUniqueCodeBlockUri ( ) ,
122124 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+ } ) ;
124133 const editor = this . _register ( this . editorPool . get ( ) ) ;
125134 const renderPromise = editor . object . render ( {
126135 codeBlockIndex : this . codeBlockStartIndex ,
0 commit comments