diff --git a/src/vs/workbench/contrib/chat/browser/chatInputWindow/chatInputWindowService.ts b/src/vs/workbench/contrib/chat/browser/chatInputWindow/chatInputWindowService.ts index e0749a05ff9..efceae4c8c5 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputWindow/chatInputWindowService.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputWindow/chatInputWindowService.ts @@ -642,7 +642,15 @@ export class ChatInputWindowService extends Disposable implements IChatInputWind let pendingBounds: IRectangle | undefined; let applyingBounds = false; const getRowHeight = () => { - let contentHeight = Math.ceil(widget.contentHeight); + // Measure the input's rendered height synchronously rather than + // reading `widget.contentHeight`, which is backed by a + // ResizeObserver and lags a frame behind. `layout()` re-lays the + // editor synchronously, so the observable is stale until the + // observer fires next frame; sizing the window to that stale height + // while the editor grows (e.g. pasting text or cycling input + // history) clips the new lines and makes the window grow + // inconsistently until the observer catches up. + let contentHeight = Math.ceil(widget.input.element.offsetHeight); if (widget.attachmentModel.size > 0) { contentHeight += Math.max(0, CHAT_INPUT_WINDOW_INITIAL_SURFACE_HEIGHT - widget.input.inputRowHeight); }