From 4b3af2a935f6437b6603f2960038b1698b441dac Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 21 May 2024 12:04:05 +0200 Subject: [PATCH] adjust max input part height for compact chat widget, keep input height separate when compute minHeight fixes https://github.com/microsoft/vscode-copilot/issues/5707 --- src/vs/workbench/contrib/chat/browser/chatInputPart.ts | 7 +++++-- .../contrib/inlineChat/browser/inlineChatWidget.ts | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts index ce0e53fa4ee3b..f34ead61db141 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts @@ -96,6 +96,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge private readonly _onDidChangeVisibility = this._register(new Emitter()); private readonly _contextResourceLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this._onDidChangeVisibility.event }); + private readonly inputEditorMaxHeight: number; private inputEditorHeight = 0; private container!: HTMLElement; @@ -150,6 +151,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge ) { super(); + this.inputEditorMaxHeight = this.options.renderStyle === 'compact' ? INPUT_EDITOR_MAX_HEIGHT / 3 : INPUT_EDITOR_MAX_HEIGHT; + this.inputEditorHasText = CONTEXT_CHAT_INPUT_HAS_TEXT.bindTo(contextKeyService); this.chatCursorAtTop = CONTEXT_CHAT_INPUT_CURSOR_AT_TOP.bindTo(contextKeyService); this.inputEditorHasFocus = CONTEXT_CHAT_INPUT_HAS_FOCUS.bindTo(contextKeyService); @@ -326,7 +329,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge this._inputEditor = this._register(scopedInstantiationService.createInstance(CodeEditorWidget, this._inputEditorElement, options, editorOptions)); this._register(this._inputEditor.onDidChangeModelContent(() => { - const currentHeight = Math.min(this._inputEditor.getContentHeight(), INPUT_EDITOR_MAX_HEIGHT); + const currentHeight = Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight); if (currentHeight !== this.inputEditorHeight) { this.inputEditorHeight = currentHeight; this._onDidChangeHeight.fire(); @@ -509,7 +512,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge return { inputEditorBorder: 2, followupsHeight: this.followupsContainer.offsetHeight, - inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), INPUT_EDITOR_MAX_HEIGHT), + inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight), inputPartHorizontalPadding: this.options.renderStyle === 'compact' ? 8 : 40, inputPartVerticalPadding: this.options.renderStyle === 'compact' ? 12 : 24, implicitContextHeight: this.attachedContextContainer.offsetHeight, diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts index 96bf08b444add..e4cfccd30bc9f 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts @@ -383,17 +383,17 @@ export class InlineChatWidget { // The chat widget is variable height and supports scrolling. It should be // at least "maxWidgetHeight" high and at most the content height. - let maxWidgetHeight = 100; + let maxWidgetOutputHeight = 100; for (const item of this._chatWidget.viewModel?.getItems() ?? []) { if (isResponseVM(item) && item.response.value.some(r => r.kind === 'textEditGroup' && !r.state?.applied)) { - maxWidgetHeight = 270; + maxWidgetOutputHeight = 270; break; } } let value = this.contentHeight; value -= this._chatWidget.contentHeight; - value += Math.min(maxWidgetHeight, this._chatWidget.contentHeight); + value += Math.min(this._chatWidget.input.contentHeight + maxWidgetOutputHeight, this._chatWidget.contentHeight); return value; }