From 47774c435a1a8df603c3167a8404090d3247853c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 23 Mar 2024 15:34:45 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20better=20height=20estimate=20for?= =?UTF-8?q?=20code=20blocks=20when=20missing=20scrollHeight?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/src/components/markdown/CodeSnippetPreview.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 2ce8d138aa..c5dac655e5 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -73,9 +73,9 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { const codeBlockRef = React.useRef(null); const codeBlockHeight = `${Math.min( MAX_PREVIEW_HEIGHT, - codeBlockRef.current?.scrollHeight - ? codeBlockRef.current?.scrollHeight - : Number.MAX_SAFE_INTEGER + codeBlockRef.current?.scrollHeight ?? + // Best estimate of height I currently could find + props.item.content.split("\n").length * 18 + 36, )}px`; return ( @@ -100,7 +100,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { new WebviewIde().showLines( props.item.description, parseInt(lines[0]) - 1, - parseInt(lines[1]) - 1 + parseInt(lines[1]) - 1, ); } else { postToIde("showVirtualFile", { @@ -154,7 +154,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { >