(t0)
| 36 | * Debounced ripgrep search across the workspace. |
| 37 | */ |
| 38 | export function GlobalSearchDialog(t0) { |
| 39 | const $ = _c(40); |
| 40 | const { |
| 41 | onDone, |
| 42 | onInsert |
| 43 | } = t0; |
| 44 | useRegisterOverlay("global-search"); |
| 45 | const { |
| 46 | columns, |
| 47 | rows |
| 48 | } = useTerminalSize(); |
| 49 | const previewOnRight = columns >= 140; |
| 50 | const visibleResults = Math.min(VISIBLE_RESULTS, Math.max(4, rows - 14)); |
| 51 | let t1; |
| 52 | if ($[0] === Symbol.for("react.memo_cache_sentinel")) { |
| 53 | t1 = []; |
| 54 | $[0] = t1; |
| 55 | } else { |
| 56 | t1 = $[0]; |
| 57 | } |
| 58 | const [matches, setMatches] = useState(t1); |
| 59 | const [truncated, setTruncated] = useState(false); |
| 60 | const [isSearching, setIsSearching] = useState(false); |
| 61 | const [query, setQuery] = useState(""); |
| 62 | const [focused, setFocused] = useState(undefined); |
| 63 | const [preview, setPreview] = useState(null); |
| 64 | const abortRef = useRef(null); |
| 65 | const timeoutRef = useRef(null); |
| 66 | let t2; |
| 67 | let t3; |
| 68 | if ($[1] === Symbol.for("react.memo_cache_sentinel")) { |
| 69 | t2 = () => () => { |
| 70 | if (timeoutRef.current) { |
| 71 | clearTimeout(timeoutRef.current); |
| 72 | } |
| 73 | abortRef.current?.abort(); |
| 74 | }; |
| 75 | t3 = []; |
| 76 | $[1] = t2; |
| 77 | $[2] = t3; |
| 78 | } else { |
| 79 | t2 = $[1]; |
| 80 | t3 = $[2]; |
| 81 | } |
| 82 | useEffect(t2, t3); |
| 83 | let t4; |
| 84 | let t5; |
| 85 | if ($[3] !== focused) { |
| 86 | t4 = () => { |
| 87 | if (!focused) { |
| 88 | setPreview(null); |
| 89 | return; |
| 90 | } |
| 91 | const controller = new AbortController(); |
| 92 | const absolute = resolvePath(getCwd(), focused.file); |
| 93 | const start = Math.max(0, focused.line - PREVIEW_CONTEXT_LINES - 1); |
| 94 | readFileInRange(absolute, start, PREVIEW_CONTEXT_LINES * 2 + 1, undefined, controller.signal).then(r => { |
| 95 | if (controller.signal.aborted) { |
nothing calls this directly
no test coverage detected