fix height computation

This commit is contained in:
sawka
2023-05-05 19:19:48 -07:00
parent 6ffe0732e0
commit aefd982b1d
2 changed files with 10 additions and 6 deletions
+5 -5
View File
@@ -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(
+5 -1
View File
@@ -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<string, any> = null;
if (model.loading.get() && model.savedHeight >= 0) {
styleVal = {height: model.savedHeight};
}
return (
<div className="renderer-container openai-renderer">
<div className="renderer-container openai-renderer" style={styleVal}>
{this.renderPrompt(cmd)}
{this.renderOutput(cmd)}
</div>