Skip to content

Commit 159dc3f

Browse files
authored
feat: render file paths (#262)
1 parent 692b1ef commit 159dc3f

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

apps/array/src/renderer/features/code-editor/components/CodeEditorPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function CodeEditorPanel({
6464
<CodeMirrorEditor
6565
content={fileContent}
6666
filePath={absolutePath}
67+
relativePath={filePath}
6768
readOnly
6869
/>
6970
</Box>

apps/array/src/renderer/features/code-editor/components/CodeMirrorDiffEditor.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Flex, SegmentedControl } from "@radix-ui/themes";
1+
import { Box, Flex, SegmentedControl, Text } from "@radix-ui/themes";
22
import { useMemo } from "react";
33
import { useCodeMirror } from "../hooks/useCodeMirror";
44
import { useEditorExtensions } from "../hooks/useEditorExtensions";
@@ -8,13 +8,15 @@ interface CodeMirrorDiffEditorProps {
88
originalContent: string;
99
modifiedContent: string;
1010
filePath?: string;
11+
relativePath?: string;
1112
onContentChange?: (content: string) => void;
1213
}
1314

1415
export function CodeMirrorDiffEditor({
1516
originalContent,
1617
modifiedContent,
1718
filePath,
19+
relativePath,
1820
onContentChange,
1921
}: CodeMirrorDiffEditorProps) {
2022
const { viewMode, setViewMode } = useDiffViewerStore();
@@ -41,11 +43,22 @@ export function CodeMirrorDiffEditor({
4143

4244
return (
4345
<Flex direction="column" height="100%">
44-
<Box
46+
<Flex
4547
px="3"
4648
py="2"
49+
align="center"
50+
justify="between"
4751
style={{ borderBottom: "1px solid var(--gray-6)", flexShrink: 0 }}
4852
>
53+
{relativePath && (
54+
<Text
55+
size="1"
56+
color="gray"
57+
style={{ fontFamily: "var(--code-font-family)" }}
58+
>
59+
{relativePath}
60+
</Text>
61+
)}
4962
<SegmentedControl.Root
5063
size="1"
5164
value={viewMode}
@@ -54,7 +67,7 @@ export function CodeMirrorDiffEditor({
5467
<SegmentedControl.Item value="split">Split</SegmentedControl.Item>
5568
<SegmentedControl.Item value="unified">Unified</SegmentedControl.Item>
5669
</SegmentedControl.Root>
57-
</Box>
70+
</Flex>
5871
<Box style={{ flex: 1, overflow: "auto" }}>
5972
<div ref={containerRef} style={{ height: "100%", width: "100%" }} />
6073
</Box>

apps/array/src/renderer/features/code-editor/components/CodeMirrorEditor.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
import { Box, Flex, Text } from "@radix-ui/themes";
12
import { useMemo } from "react";
23
import { useCodeMirror } from "../hooks/useCodeMirror";
34
import { useEditorExtensions } from "../hooks/useEditorExtensions";
45

56
interface CodeMirrorEditorProps {
67
content: string;
78
filePath?: string;
9+
relativePath?: string;
810
readOnly?: boolean;
911
}
1012

1113
export function CodeMirrorEditor({
1214
content,
1315
filePath,
16+
relativePath,
1417
readOnly = false,
1518
}: CodeMirrorEditorProps) {
1619
const extensions = useEditorExtensions(filePath, readOnly);
@@ -20,5 +23,28 @@ export function CodeMirrorEditor({
2023
);
2124
const containerRef = useCodeMirror(options);
2225

23-
return <div ref={containerRef} style={{ height: "100%", width: "100%" }} />;
26+
if (!relativePath) {
27+
return <div ref={containerRef} style={{ height: "100%", width: "100%" }} />;
28+
}
29+
30+
return (
31+
<Flex direction="column" height="100%">
32+
<Box
33+
px="3"
34+
py="2"
35+
style={{ borderBottom: "1px solid var(--gray-6)", flexShrink: 0 }}
36+
>
37+
<Text
38+
size="1"
39+
color="gray"
40+
style={{ fontFamily: "var(--code-font-family)" }}
41+
>
42+
{relativePath}
43+
</Text>
44+
</Box>
45+
<Box style={{ flex: 1, overflow: "auto" }}>
46+
<div ref={containerRef} style={{ height: "100%", width: "100%" }} />
47+
</Box>
48+
</Flex>
49+
);
2450
}

apps/array/src/renderer/features/code-editor/components/DiffEditorPanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ export function DiffEditorPanel({
9696
originalContent={originalContent ?? ""}
9797
modifiedContent={modifiedContent ?? ""}
9898
filePath={absolutePath}
99+
relativePath={filePath}
99100
onContentChange={handleContentChange}
100101
/>
101102
) : (
102103
<CodeMirrorEditor
103104
content={content ?? ""}
104105
filePath={absolutePath}
106+
relativePath={filePath}
105107
readOnly
106108
/>
107109
)}

0 commit comments

Comments
 (0)