Skip to content

Commit 31b6bf6

Browse files
authored
Fix terminal output last line clipping in chat terminal tool progress (#308842)
fix #307571
1 parent 12905f7 commit 31b6bf6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatTerminalToolProgressPart.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ div.chat-terminal-content-part.progress-step > div.chat-terminal-output-containe
177177
background: inherit;
178178
}
179179
.chat-terminal-output-body {
180-
padding: 5px 0px 1px;
180+
padding: 5px 0px 3px;
181181
max-width: 100%;
182182
box-sizing: border-box;
183183
min-height: 0;

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,13 +1479,17 @@ class ChatTerminalToolOutputSection extends Disposable {
14791479
const scrollableDomNode = this._scrollableContainer.getDomNode();
14801480
const rowHeight = this._computeRowHeightPx();
14811481
const padding = this._getOutputPadding();
1482-
const minHeight = rowHeight * MIN_OUTPUT_ROWS + padding;
14831482
const maxHeight = rowHeight * MAX_OUTPUT_ROWS + padding;
14841483
const contentHeight = this._getOutputContentHeight(lineCount, rowHeight, padding);
14851484
const clampedHeight = Math.min(contentHeight, maxHeight);
1486-
const measuredBodyHeight = Math.max(this._outputBody.clientHeight, minHeight);
1487-
const appliedHeight = Math.min(clampedHeight, measuredBodyHeight);
1488-
scrollableDomNode.style.height = appliedHeight < maxHeight ? `${appliedHeight}px` : '';
1485+
// Use the line-count-based calculation directly rather than constraining by
1486+
// _outputBody.clientHeight. The DOM measurement races with xterm's async
1487+
// rendering — when new lines arrive, clientHeight reflects the stale
1488+
// (pre-render) size, causing the viewport to be too short and clipping the
1489+
// last line. The calculated height still has enough headroom because it
1490+
// includes the output padding and may round slightly differently from
1491+
// xterm's actual rendered cell height.
1492+
scrollableDomNode.style.height = clampedHeight < maxHeight ? `${clampedHeight}px` : '';
14891493
this._scrollableContainer.scanDomNode();
14901494
}
14911495

@@ -1512,9 +1516,7 @@ class ChatTerminalToolOutputSection extends Disposable {
15121516

15131517
private _getOutputContentHeight(lineCount: number, rowHeight: number, padding: number): number {
15141518
const contentRows = Math.max(lineCount, MIN_OUTPUT_ROWS);
1515-
// Always add an extra row for buffer space to prevent the last line from being cut off during streaming
1516-
const adjustedRows = contentRows + 1;
1517-
return (adjustedRows * rowHeight) + padding;
1519+
return (contentRows * rowHeight) + padding;
15181520
}
15191521

15201522
private _getOutputPadding(): number {

0 commit comments

Comments
 (0)