Fixes rendering of response that is below the fold (#191337)

Steps:
1. ask `reverse a linked list`
2. scroll up right after hitting ENTER
3. wait for response to finish
4. scroll down

the view should grow to the response.
This commit is contained in:
Tyler James Leonhardt
2023-08-25 14:17:58 -07:00
committed by GitHub
parent 2672173f73
commit 71fd986efb
2 changed files with 20 additions and 5 deletions
@@ -354,7 +354,15 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
templateData.contextKeyService));
}
element.currentRenderedHeight = templateData.rowContainer.offsetHeight;
const newHeight = templateData.rowContainer.offsetHeight;
const fireEvent = !element.currentRenderedHeight || element.currentRenderedHeight !== newHeight;
element.currentRenderedHeight = newHeight;
if (fireEvent) {
const disposable = this._register(dom.scheduleAtNextAnimationFrame(() => {
disposable.dispose();
this._onDidChangeItemHeight.fire({ element, height: newHeight });
}));
}
}
private renderWelcomeMessage(element: IChatWelcomeMessageViewModel, templateData: IChatListItemTemplate) {
@@ -381,7 +389,15 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
}
}
element.currentRenderedHeight = templateData.rowContainer.offsetHeight;
const newHeight = templateData.rowContainer.offsetHeight;
const fireEvent = !element.currentRenderedHeight || element.currentRenderedHeight !== newHeight;
element.currentRenderedHeight = newHeight;
if (fireEvent) {
const disposable = this._register(dom.scheduleAtNextAnimationFrame(() => {
disposable.dispose();
this._onDidChangeItemHeight.fire({ element, height: newHeight });
}));
}
}
/**
@@ -530,7 +530,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
this._register(this.renderer.onDidChangeItemHeight(() => this.layoutDynamicChatTreeItemMode()));
}
layoutDynamicChatTreeItemMode(allowRecurse = true): void {
layoutDynamicChatTreeItemMode(): void {
if (!this.viewModel) {
return;
}
@@ -554,10 +554,9 @@ export class ChatWidget extends Disposable implements IChatWidget {
this.container.offsetWidth
);
if (needsRerender && allowRecurse) {
if (needsRerender) {
// TODO: figure out a better place to reveal the last element
revealLastElement(this.tree);
this.layoutDynamicChatTreeItemMode(false);
}
}