mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 21:58:29 -05:00
chat: fix intermittent empty code blocks in chat responses (#308414)
Schedule a deferred editor render at the end of CodeBlockPart.render() to ensure view lines are painted even when earlier render passes were dropped (e.g. when isConnected is false during initial render). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -601,12 +601,21 @@ export class View extends ViewEventHandler {
|
||||
inputLatency.onRenderStart();
|
||||
|
||||
if (!this.domNode.domNode.isConnected) {
|
||||
const model = this._context.viewModel.model;
|
||||
if (model.uri.scheme === 'vscode-chat-code-block') {
|
||||
console.warn(`[EditorView] Render dropped: isConnected=false for ${model.uri.toString()}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const viewPartsToRender = this._getViewPartsToRender();
|
||||
if (!this._viewLines.shouldRender() && viewPartsToRender.length === 0) {
|
||||
const viewLinesShouldRender = this._viewLines.shouldRender();
|
||||
if (!viewLinesShouldRender && viewPartsToRender.length === 0) {
|
||||
// Nothing to render
|
||||
const model = this._context.viewModel.model;
|
||||
if (model.uri.scheme === 'vscode-chat-code-block') {
|
||||
console.warn(`[EditorView] Render dropped: nothing to render for ${model.uri.toString()}, viewLines.shouldRender=${viewLinesShouldRender}, viewParts=${viewPartsToRender.length}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -475,6 +475,13 @@ export class CodeBlockPart extends Disposable {
|
||||
}
|
||||
|
||||
this.layout();
|
||||
|
||||
// The editor element is typically not yet connected to the live DOM at
|
||||
// this point (the caller still needs to attach it). Any render pass
|
||||
// scheduled by setText/setLanguage/layout is silently dropped by the
|
||||
// editor view when `isConnected` is false. Schedule a deferred render
|
||||
// so the view lines are painted once the element is in the document.
|
||||
this.editor.renderAsync(true);
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user