Skip to content

Commit 6ee39fa

Browse files
committed
Remove unnecessary memo wrapper from CommandOutputViewer component
1 parent fa94be4 commit 6ee39fa

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

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

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1-
import { forwardRef, memo, useEffect, useRef } from "react"
1+
import { forwardRef, useEffect, useRef } from "react"
22
import { Virtuoso, VirtuosoHandle } from "react-virtuoso"
33
import { cn } from "../../lib/utils"
44

55
interface CommandOutputViewerProps {
66
output: string
77
}
88

9-
const CommandOutputViewer = memo(
10-
forwardRef<HTMLDivElement, CommandOutputViewerProps>(({ output }, ref) => {
11-
const virtuosoRef = useRef<VirtuosoHandle>(null)
12-
const lines = output.split("\n")
9+
const CommandOutputViewer = forwardRef<HTMLDivElement, CommandOutputViewerProps>(({ output }, ref) => {
10+
const virtuosoRef = useRef<VirtuosoHandle>(null)
11+
const lines = output.split("\n")
1312

14-
useEffect(() => {
15-
// Scroll to the bottom when output changes
16-
if (virtuosoRef.current && typeof virtuosoRef.current.scrollToIndex === "function") {
17-
virtuosoRef.current.scrollToIndex({
18-
index: lines.length - 1,
19-
behavior: "auto",
20-
})
21-
}
22-
}, [output, lines.length])
13+
useEffect(() => {
14+
// Scroll to the bottom when output changes
15+
if (virtuosoRef.current && typeof virtuosoRef.current.scrollToIndex === "function") {
16+
virtuosoRef.current.scrollToIndex({
17+
index: lines.length - 1,
18+
behavior: "auto",
19+
})
20+
}
21+
}, [output, lines.length])
2322

24-
return (
25-
<div ref={ref} className="w-full rounded-b-md bg-[var(--vscode-editor-background)] h-[300px]">
26-
<Virtuoso
27-
ref={virtuosoRef}
28-
className="h-full"
29-
totalCount={lines.length}
30-
itemContent={(index) => (
31-
<div
32-
className={cn(
33-
"px-3 py-0.5",
34-
"font-mono text-vscode-editor-foreground",
35-
"text-[var(--vscode-editor-font-size,var(--vscode-font-size,12px))]",
36-
"font-[var(--vscode-editor-font-family)]",
37-
"whitespace-pre-wrap break-all anywhere",
38-
)}>
39-
{lines[index]}
40-
</div>
41-
)}
42-
increaseViewportBy={{ top: 300, bottom: 300 }}
43-
followOutput="auto"
44-
/>
45-
</div>
46-
)
47-
}),
48-
)
23+
return (
24+
<div ref={ref} className="w-full rounded-b-md bg-[var(--vscode-editor-background)] h-[300px]">
25+
<Virtuoso
26+
ref={virtuosoRef}
27+
className="h-full"
28+
totalCount={lines.length}
29+
itemContent={(index) => (
30+
<div
31+
className={cn(
32+
"px-3 py-0.5",
33+
"font-mono text-vscode-editor-foreground",
34+
"text-[var(--vscode-editor-font-size,var(--vscode-font-size,12px))]",
35+
"font-[var(--vscode-editor-font-family)]",
36+
"whitespace-pre-wrap break-all anywhere",
37+
)}>
38+
{lines[index]}
39+
</div>
40+
)}
41+
increaseViewportBy={{ top: 300, bottom: 300 }}
42+
followOutput="auto"
43+
/>
44+
</div>
45+
)
46+
})
4947

5048
CommandOutputViewer.displayName = "CommandOutputViewer"
5149

0 commit comments

Comments
 (0)