Skip to content

Commit 8e21062

Browse files
committed
Don't render empty code blocks
1 parent e723058 commit 8e21062

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

webview-ui/src/components/common/CodeAccordian.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ const CodeAccordian = ({
117117
)}
118118
{(!(path || isFeedback || isConsoleLogs) || isExpanded) && (
119119
<div
120-
//className="code-block-scrollable" this doesn't seem to be necessary anymore, on silicon macs it shows the native mac scrollbar instead of the vscode styled one
121120
style={{
122121
overflowX: "auto",
123122
overflowY: "hidden",

webview-ui/src/components/common/CodeBlock.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ const CodeBlock = memo(
598598
[source, rawSource, copyWithFeedback],
599599
)
600600

601+
if (source?.length === 0) {
602+
return null
603+
}
604+
601605
return (
602606
<CodeBlockContainer ref={codeBlockRef}>
603607
<StyledPre
@@ -607,9 +611,7 @@ const CodeBlock = memo(
607611
windowshade={windowShade ? "true" : "false"}
608612
collapsedHeight={collapsedHeight}
609613
onMouseDown={() => updateCodeBlockButtonPosition(true)}
610-
onMouseUp={() => updateCodeBlockButtonPosition(false)}
611-
// onScroll prop is removed - handled by the useEffect scroll listener now
612-
>
614+
onMouseUp={() => updateCodeBlockButtonPosition(false)}>
613615
<div dangerouslySetInnerHTML={{ __html: highlightedCode }} />
614616
</StyledPre>
615617
{!isSelecting && (
@@ -685,10 +687,7 @@ const CodeBlock = memo(
685687
// After UI updates, ensure code block is visible and update button position
686688
setTimeout(
687689
() => {
688-
codeBlock.scrollIntoView({
689-
behavior: "smooth",
690-
block: "nearest",
691-
})
690+
codeBlock.scrollIntoView({ behavior: "smooth", block: "nearest" })
692691

693692
// Wait for scroll to complete before updating button position
694693
setTimeout(() => {

0 commit comments

Comments
 (0)