From aefd982b1d53d49e4926d794d2391a61a206f90b Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 5 May 2023 19:19:48 -0700 Subject: [PATCH] fix height computation --- src/linecomps.tsx | 10 +++++----- src/view/openai.tsx | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/linecomps.tsx b/src/linecomps.tsx index fd314bcd..17475905 100644 --- a/src/linecomps.tsx +++ b/src/linecomps.tsx @@ -384,16 +384,14 @@ class LineCmd extends React.Component<{screen : LineContainerModel, line : LineT getTerminalRendererHeight(cmd : Cmd) : number { let {screen, line, width, topBorder, renderMode} = this.props; // header is 36px tall, padding+border = 6px - // header is 16px tall with hide-prompt, padding+border = 6px // zero-terminal is 0px // terminal-wrapper overhead is 11px (margin/padding) // inner-height, if zero-lines => 42 // else: 53+(lines*lineheight) - let hidePrompt = this.getIsHidePrompt(); - let height = (hidePrompt ? 22 : 42); // height of zero height terminal + let height = 36 + 6; // height of zero height terminal let usedRows = screen.getUsedRows(lineutil.getRendererContext(line), line, cmd, width); if (usedRows > 0) { - height = 53 + termHeightFromRows(usedRows, GlobalModel.termFontSize.get()); + height = 36 + 6 + 11 + termHeightFromRows(usedRows, GlobalModel.termFontSize.get()); } return height; } @@ -421,9 +419,11 @@ class LineCmd extends React.Component<{screen : LineContainerModel, line : LineT height = this.getTerminalRendererHeight(cmd); } else { + // header is 16px tall with hide-prompt, 36px otherwise let {screen, line, width} = this.props; + let hidePrompt = this.getIsHidePrompt(); let usedRows = screen.getUsedRows(lineutil.getRendererContext(line), line, cmd, width); - height = 36 + usedRows; + height = (hidePrompt ? 16 + 6 : 36 + 6) + usedRows; } let formattedTime = lineutil.getLineDateTimeStr(line.ts); let mainDivCn = cn( diff --git a/src/view/openai.tsx b/src/view/openai.tsx index 491fec25..4e4fd184 100644 --- a/src/view/openai.tsx +++ b/src/view/openai.tsx @@ -193,8 +193,12 @@ class OpenAIRenderer extends React.Component<{model : OpenAIRendererModel}> { render() { let model : OpenAIRendererModel = this.props.model; let cmd = model.rawCmd; + let styleVal : Record = null; + if (model.loading.get() && model.savedHeight >= 0) { + styleVal = {height: model.savedHeight}; + } return ( -
+
{this.renderPrompt(cmd)} {this.renderOutput(cmd)}