From 12a9bc3ed94fab3071529b5304d46bcc5b4fe756 Mon Sep 17 00:00:00 2001 From: Bryant Chandler Date: Tue, 5 Aug 2025 16:18:03 -0700 Subject: feat(core, cli): Introduce high-performance FileSearch engine (#5136) Co-authored-by: Jacob Richman --- packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx') diff --git a/packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx b/packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx index 1cc7e602..3fb9217e 100644 --- a/packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx +++ b/packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx @@ -41,12 +41,17 @@ export function useReverseSearchCompletion( navigateDown, } = useCompletion(); - // whenever reverseSearchActive is on, filter history useEffect(() => { if (!reverseSearchActive) { resetCompletionState(); + } + }, [reverseSearchActive, resetCompletionState]); + + useEffect(() => { + if (!reverseSearchActive) { return; } + const q = buffer.text.toLowerCase(); const matches = shellHistory.reduce((acc, cmd) => { const idx = cmd.toLowerCase().indexOf(q); @@ -55,6 +60,7 @@ export function useReverseSearchCompletion( } return acc; }, []); + setSuggestions(matches); setShowSuggestions(matches.length > 0); setActiveSuggestionIndex(matches.length > 0 ? 0 : -1); @@ -62,7 +68,6 @@ export function useReverseSearchCompletion( buffer.text, shellHistory, reverseSearchActive, - resetCompletionState, setActiveSuggestionIndex, setShowSuggestions, setSuggestions, -- cgit v1.2.3