Skip to content

Commit adcd079

Browse files
committed
Merge branch 'preview'
2 parents 729d31b + 47774c4 commit adcd079

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gui/src/components/markdown/CodeSnippetPreview.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
7373
const codeBlockRef = React.useRef<HTMLDivElement>(null);
7474
const codeBlockHeight = `${Math.min(
7575
MAX_PREVIEW_HEIGHT,
76-
codeBlockRef.current?.scrollHeight
77-
? codeBlockRef.current?.scrollHeight
78-
: Number.MAX_SAFE_INTEGER
76+
codeBlockRef.current?.scrollHeight ??
77+
// Best estimate of height I currently could find
78+
props.item.content.split("\n").length * 18 + 36,
7979
)}px`;
8080

8181
return (
@@ -100,7 +100,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
100100
new WebviewIde().showLines(
101101
props.item.description,
102102
parseInt(lines[0]) - 1,
103-
parseInt(lines[1]) - 1
103+
parseInt(lines[1]) - 1,
104104
);
105105
} else {
106106
postToIde("showVirtualFile", {
@@ -154,7 +154,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
154154
>
155155
<StyledMarkdownPreview
156156
source={`${fence}${getMarkdownLanguageTagForFile(
157-
props.item.description
157+
props.item.description,
158158
)}\n${props.item.content.trim()}\n${fence}`}
159159
showCodeBorder={false}
160160
/>

0 commit comments

Comments
 (0)