(t0)
| 23 | * No scrolling - renders all lines (max 400 due to parsing limits). |
| 24 | */ |
| 25 | export function DiffDetailView(t0) { |
| 26 | const $ = _c(53); |
| 27 | const { |
| 28 | filePath, |
| 29 | hunks, |
| 30 | isLargeFile, |
| 31 | isBinary, |
| 32 | isTruncated, |
| 33 | isUntracked |
| 34 | } = t0; |
| 35 | const { |
| 36 | columns |
| 37 | } = useTerminalSize(); |
| 38 | const needsFileContent = filePath && !isBinary && !isLargeFile && !isUntracked && hunks.length > 0; |
| 39 | const { |
| 40 | firstLine, |
| 41 | fileContent |
| 42 | } = useMemo(() => { |
| 43 | if (!needsFileContent) { |
| 44 | return { |
| 45 | firstLine: null, |
| 46 | fileContent: undefined |
| 47 | }; |
| 48 | } |
| 49 | |
| 50 | // Avoid reading full file contents on guard branches that already know they |
| 51 | // will render a placeholder or an empty-diff message. This is a known |
| 52 | // long-history perf hazard because diff previews can otherwise drag large |
| 53 | // rendered files into memory on the hot path for no visible benefit. |
| 54 | const fullPath = resolve(getCwd(), filePath); |
| 55 | const content = readFileSafe(fullPath); |
| 56 | return { |
| 57 | firstLine: content?.split("\n")[0] ?? null, |
| 58 | fileContent: content ?? undefined |
| 59 | }; |
| 60 | }, [filePath, needsFileContent]); |
| 61 | if (isUntracked) { |
| 62 | let t2; |
| 63 | if ($[7] !== filePath) { |
| 64 | t2 = <Text bold={true}>{filePath}</Text>; |
| 65 | $[7] = filePath; |
| 66 | $[8] = t2; |
| 67 | } else { |
| 68 | t2 = $[8]; |
| 69 | } |
| 70 | let t3; |
| 71 | if ($[9] === Symbol.for("react.memo_cache_sentinel")) { |
| 72 | t3 = <Text dimColor={true}> (untracked)</Text>; |
| 73 | $[9] = t3; |
| 74 | } else { |
| 75 | t3 = $[9]; |
| 76 | } |
| 77 | let t4; |
| 78 | if ($[10] !== t2) { |
| 79 | t4 = <Box>{t2}{t3}</Box>; |
| 80 | $[10] = t2; |
| 81 | $[11] = t4; |
| 82 | } else { |
nothing calls this directly
no test coverage detected