fix: fire onDidChangeContentHeight when attaching context (#221486)

This commit is contained in:
Joyce Er
2024-07-11 11:21:55 -07:00
committed by GitHub
parent 8287595ec8
commit 44d09d36d8
3 changed files with 12 additions and 9 deletions
@@ -347,7 +347,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}
}
attachContext(contentReferences: IChatRequestVariableEntry[]): void {
attachContext(overwrite: boolean, ...contentReferences: IChatRequestVariableEntry[]): void {
if (overwrite) {
this._attachedContext.clear();
}
if (contentReferences.length > 0) {
for (const reference of contentReferences) {
this._attachedContext.add(reference);
@@ -489,6 +493,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
}
private initAttachedContext(container: HTMLElement) {
const oldHeight = container.offsetHeight;
dom.clearNode(container);
this.attachedContextDisposables.clear();
dom.setVisibility(Boolean(this.attachedContext.size), this.attachedContextContainer);
@@ -547,6 +552,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
});
this.attachedContextDisposables.add(disp);
});
if (oldHeight !== container.offsetHeight) {
this._onDidChangeHeight.fire();
}
}
async renderFollowups(items: IChatFollowup[] | undefined, response: IChatResponseViewModel | undefined): Promise<void> {
@@ -792,14 +792,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
setContext(overwrite: boolean, ...contentReferences: IChatRequestVariableEntry[]) {
if (overwrite) {
this.inputPart.clearContext();
}
this.inputPart.attachContext(contentReferences);
if (this.bodyDimension) {
this.layout(this.bodyDimension.height, this.bodyDimension.width);
}
this.inputPart.attachContext(overwrite, ...contentReferences);
}
getCodeBlockInfosForResponse(response: IChatResponseViewModel): IChatCodeBlockInfo[] {
@@ -534,6 +534,7 @@
.interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-icon-label .monaco-button.codicon.codicon-close,
.interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-button.codicon.codicon-close {
color: var(--vscode-descriptionForeground);
cursor: pointer;
}
.interactive-session .chat-attached-context .chat-attached-context-attachment .monaco-icon-label .codicon {