From 02b19c9c9bee3782b49fe88efd1770fe35efcfe1 Mon Sep 17 00:00:00 2001 From: Johannes Date: Wed, 26 Mar 2025 11:58:17 +0100 Subject: [PATCH] cap input/output rendering to 13 lines fixes https://github.com/microsoft/vscode/issues/244541 --- .../browser/chatContentParts/chatToolInvocationPart.ts | 2 ++ src/vs/workbench/contrib/chat/browser/codeBlockPart.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInvocationPart.ts b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInvocationPart.ts index 9b748015b767a..5c3ef465a0bd9 100644 --- a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInvocationPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInvocationPart.ts @@ -231,6 +231,7 @@ class ChatToolInvocationSubPart extends Disposable { const codeBlockRenderOptions: ICodeBlockRenderOptions = { hideToolbar: true, reserveWidth: 19, + maxHeightInLines: 13, verticalPadding: 5, editorOptions: { wordWrap: 'on', @@ -480,6 +481,7 @@ class ChatToolInvocationSubPart extends Disposable { { hideToolbar: true, reserveWidth: 19, + maxHeightInLines: 13, verticalPadding: 5, editorOptions: { wordWrap: 'on' diff --git a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts index 7d24d44f28035..399a2f9e36f98 100644 --- a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts +++ b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts @@ -142,6 +142,7 @@ export interface ICodeBlockRenderOptions { verticalPadding?: number; reserveWidth?: number; editorOptions?: IEditorOptions; + maxHeightInLines?: number; } const defaultCodeblockPadding = 10; @@ -366,9 +367,15 @@ export class CodeBlockPart extends Disposable { layout(width: number): void { const contentHeight = this.getContentHeight(); + + let height = contentHeight; + if (this.currentCodeBlockData?.renderOptions?.maxHeightInLines) { + height = Math.min(contentHeight, this.editor.getOption(EditorOption.lineHeight) * this.currentCodeBlockData?.renderOptions?.maxHeightInLines); + } + const editorBorder = 2; width = width - editorBorder - (this.currentCodeBlockData?.renderOptions?.reserveWidth ?? 0); - this.editor.layout({ width, height: contentHeight }); + this.editor.layout({ width, height }); this.updatePaddingForLayout(); }