@@ -33,7 +33,7 @@ import { IMarkdownRenderResult, MarkdownRenderer } from 'vs/editor/browser/widge
33
33
import { Range } from 'vs/editor/common/core/range' ;
34
34
import { IResolvedTextEditorModel , ITextModelService } from 'vs/editor/common/services/resolverService' ;
35
35
import { localize } from 'vs/nls' ;
36
- import { createActionViewItem , IMenuEntryActionViewItemOptions , MenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
36
+ import { IMenuEntryActionViewItemOptions , MenuEntryActionViewItem , createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
37
37
import { MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar' ;
38
38
import { MenuId , MenuItemAction } from 'vs/platform/actions/common/actions' ;
39
39
import { ICommandService } from 'vs/platform/commands/common/commands' ;
@@ -918,17 +918,13 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
918
918
}
919
919
920
920
const sessionId = isResponseVM ( element ) || isRequestVM ( element ) ? element . sessionId : '' ;
921
- const modelEntry = this . codeBlockModelCollection . get ( sessionId , element , index ) ;
922
- if ( ! modelEntry ) {
923
- console . error ( 'Trying to render code block without model' , element . id , index ) ;
924
- return $ ( 'div' ) ;
925
- }
921
+ const modelEntry = this . codeBlockModelCollection . getOrCreate ( sessionId , element , index ) ;
926
922
vulns = modelEntry . vulns ;
927
923
textModel = modelEntry . model ;
928
924
}
929
925
930
926
const hideToolbar = isResponseVM ( element ) && element . errorDetails ?. responseIsFiltered ;
931
- const ref = this . renderCodeBlock ( { languageId, textModel, codeBlockIndex : index , element, range, hideToolbar, parentContextKeyService : templateData . contextKeyService , vulns } ) ;
927
+ const ref = this . renderCodeBlock ( { languageId, textModel, codeBlockIndex : index , element, range, hideToolbar, parentContextKeyService : templateData . contextKeyService , vulns } , text ) ;
932
928
933
929
// Attach this after updating text/layout of the editor, so it should only be fired when the size updates later (horizontal scrollbar, wrapping)
934
930
// not during a renderElement OR a progressive render (when we will be firing this event anyway at the end of the render)
@@ -975,9 +971,13 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
975
971
} ;
976
972
}
977
973
978
- private renderCodeBlock ( data : ICodeBlockData ) : IDisposableReference < CodeBlockPart > {
974
+ private renderCodeBlock ( data : ICodeBlockData , text : string ) : IDisposableReference < CodeBlockPart > {
979
975
const ref = this . _editorPool . get ( ) ;
980
976
const editorInfo = ref . object ;
977
+ if ( isResponseVM ( data . element ) ) {
978
+ this . codeBlockModelCollection . update ( data . element . sessionId , data . element , data . codeBlockIndex , { text, languageId : data . languageId } ) ;
979
+ }
980
+
981
981
editorInfo . render ( data , this . _currentLayoutWidth , this . rendererOptions . editableCodeBlock ) ;
982
982
983
983
return ref ;
0 commit comments