Skip to content

Commit 377476a

Browse files
authored
fix: wrap option (#66)
1 parent 5280482 commit 377476a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/components/wrap.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@ import { Button } from "./ui/button";
77
import type { FC } from "react";
88

99
export const Wrap: FC = () => {
10-
const explorer = useExplorer();
10+
const {
11+
tool,
12+
viewModes: { astView, pathView },
13+
wrap,
14+
setWrap,
15+
} = useExplorer();
1116

12-
if (explorer.tool === "ast" && explorer.astViewMode !== "json") {
13-
return null;
14-
}
17+
const isAstViewNotJson = tool === "ast" && astView !== "json";
18+
const isPathViewNotCode = tool === "path" && pathView !== "code";
1519

16-
if (explorer.tool === "path" && explorer.pathViewMode !== "code") {
17-
return null;
18-
}
20+
if (isAstViewNotJson || isPathViewNotCode) return null;
1921

2022
return (
2123
<Button
22-
onClick={() => explorer.setWrap(!explorer.wrap)}
23-
variant={explorer.wrap ? "outline" : "ghost"}
24+
onClick={() => setWrap(!wrap)}
25+
variant={wrap ? "outline" : "ghost"}
2426
className={cn(
2527
"flex items-center gap-2",
26-
!explorer.wrap &&
27-
"text-muted-foreground border border-transparent",
28+
!wrap && "text-muted-foreground border border-transparent",
2829
)}
2930
>
3031
<WrapTextIcon size={16} />

0 commit comments

Comments
 (0)