({ text }: { text: string })
| 793 | } |
| 794 | |
| 795 | function SplitPatchView({ text }: { text: string }) { |
| 796 | const files = useMemo(() => parseUnifiedPatch(text), [text]); |
| 797 | if (!files) return <PatchTextView text={text} />; |
| 798 | const showFileHeaders = files.length > 1; |
| 799 | |
| 800 | return ( |
| 801 | <div style={{ maxHeight: 560, overflowY: "auto", overflowX: "hidden", background: "var(--bg)" }}> |
| 802 | {files.map((file, fileIndex) => ( |
| 803 | <div |
| 804 | key={fileIndex} |
| 805 | style={{ |
| 806 | minWidth: 0, |
| 807 | borderTop: fileIndex === 0 ? "none" : "1px solid var(--border)", |
| 808 | fontFamily: "var(--font-mono)", |
| 809 | fontSize: 12, |
| 810 | lineHeight: 1.55, |
| 811 | }} |
| 812 | > |
| 813 | {showFileHeaders && ( |
| 814 | <div |
| 815 | style={{ |
| 816 | display: "grid", |
| 817 | gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)", |
| 818 | position: "sticky", |
| 819 | top: 0, |
| 820 | zIndex: 1, |
| 821 | background: "var(--bg-panel)", |
| 822 | borderBottom: "1px solid var(--border)", |
| 823 | }} |
| 824 | > |
| 825 | <SplitDiffHeader title={file.oldPath || "Before"} side="left" /> |
| 826 | <SplitDiffHeader title={file.newPath || "After"} side="right" /> |
| 827 | </div> |
| 828 | )} |
| 829 | |
| 830 | <div style={{ display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)" }}> |
| 831 | {file.rows.map((row, rowIndex) => { |
| 832 | if (row.type === "hunk") { |
| 833 | return null; |
| 834 | } |
| 835 | |
| 836 | return ( |
| 837 | <div key={rowIndex} style={{ display: "contents" }}> |
| 838 | <SplitDiffCellView cell={row.left} side="left" /> |
| 839 | <SplitDiffCellView cell={row.right} side="right" /> |
| 840 | </div> |
| 841 | ); |
| 842 | })} |
| 843 | </div> |
| 844 | </div> |
| 845 | ))} |
| 846 | </div> |
| 847 | ); |
| 848 | } |
| 849 | |
| 850 | function SplitDiffHeader({ title, side }: { title: string; side: "left" | "right" }) { |
| 851 | return ( |
nothing calls this directly
no test coverage detected