@@ -47,28 +47,28 @@ export class ChatAttachmentsContentPart extends Disposable {
47
47
this . attachedContextDisposables . clear ( ) ;
48
48
const hoverDelegate = this . attachedContextDisposables . add ( createInstantHoverDelegate ( ) ) ;
49
49
50
- this . variables . forEach ( async ( attachment ) => {
50
+ for ( const attachment of this . variables ) {
51
51
const resource = URI . isUri ( attachment . value ) ? attachment . value : attachment . value && typeof attachment . value === 'object' && 'uri' in attachment . value && URI . isUri ( attachment . value . uri ) ? attachment . value . uri : undefined ;
52
52
const range = attachment . value && typeof attachment . value === 'object' && 'range' in attachment . value && Range . isIRange ( attachment . value . range ) ? attachment . value . range : undefined ;
53
+ const correspondingContentReference = this . contentReferences . find ( ( ref ) => ( typeof ref . reference === 'object' && 'variableName' in ref . reference && ref . reference . variableName === attachment . name ) || ( URI . isUri ( ref . reference ) && basename ( ref . reference . path ) === attachment . name ) ) ;
53
54
54
55
let widget ;
55
56
if ( isElementVariableEntry ( attachment ) ) {
56
57
widget = this . instantiationService . createInstance ( ElementChatAttachmentWidget , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
57
58
} else if ( isImageVariableEntry ( attachment ) ) {
58
59
widget = this . instantiationService . createInstance ( ImageAttachmentWidget , resource , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
59
60
} else if ( resource && ( attachment . kind === 'file' || attachment . kind === 'directory' ) ) {
60
- widget = this . instantiationService . createInstance ( FileAttachmentWidget , resource , range , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
61
+ widget = this . instantiationService . createInstance ( FileAttachmentWidget , resource , range , attachment , correspondingContentReference , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
61
62
} else if ( isPasteVariableEntry ( attachment ) ) {
62
63
widget = this . instantiationService . createInstance ( PasteAttachmentWidget , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
63
64
} else if ( resource && isNotebookOutputVariableEntry ( attachment ) ) {
64
65
widget = this . instantiationService . createInstance ( NotebookCellOutputChatAttachmentWidget , resource , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
65
66
} else if ( isSCMHistoryItemVariableEntry ( attachment ) ) {
66
67
widget = this . instantiationService . createInstance ( SCMHistoryItemAttachmentWidget , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
67
68
} else {
68
- widget = this . instantiationService . createInstance ( DefaultChatAttachmentWidget , resource , range , attachment , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
69
+ widget = this . instantiationService . createInstance ( DefaultChatAttachmentWidget , resource , range , attachment , correspondingContentReference , undefined , { shouldFocusClearButton : false , supportsDeletion : false } , container , this . _contextResourceLabels , hoverDelegate ) ;
69
70
}
70
71
71
- const correspondingContentReference = this . contentReferences . find ( ( ref ) => ( typeof ref . reference === 'object' && 'variableName' in ref . reference && ref . reference . variableName === attachment . name ) || ( URI . isUri ( ref . reference ) && basename ( ref . reference . path ) === attachment . name ) ) ;
72
72
const isAttachmentOmitted = correspondingContentReference ?. options ?. status ?. kind === ChatResponseReferencePartStatusKind . Omitted ;
73
73
const isAttachmentPartialOrOmitted = isAttachmentOmitted || correspondingContentReference ?. options ?. status ?. kind === ChatResponseReferencePartStatusKind . Partial ;
74
74
@@ -89,6 +89,7 @@ export class ChatAttachmentsContentPart extends Disposable {
89
89
}
90
90
91
91
if ( this . attachedContextDisposables . isDisposed ) {
92
+ widget . dispose ( ) ;
92
93
return ;
93
94
}
94
95
@@ -97,6 +98,6 @@ export class ChatAttachmentsContentPart extends Disposable {
97
98
}
98
99
99
100
this . attachedContextDisposables . add ( widget ) ;
100
- } ) ;
101
+ }
101
102
}
102
103
}
0 commit comments