MCPcopy Index your code
hub / github.com/codeaashu/claude-code / useSearchHighlight

Function useSearchHighlight

src/ink/hooks/use-search-highlight.ts:18–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 * won't highlight; that's acceptable — we highlight what you see.
17 */
18export function useSearchHighlight(): {
19 setQuery: (query: string) => void
20 /** Paint an existing DOM subtree (from the MAIN tree) to a fresh
21 * Screen at its natural height, scan. Element-relative positions
22 * (row 0 = element top). Zero context duplication — the element
23 * IS the one built with all real providers. */
24 scanElement: (el: DOMElement) => MatchPosition[]
25 /** Position-based CURRENT highlight. Every frame writes yellow at
26 * positions[currentIdx] + rowOffset. The scan-highlight (inverse on
27 * all matches) still runs — this overlays on top. rowOffset tracks
28 * scroll; positions stay stable (message-relative). null clears. */
29 setPositions: (
30 state: {
31 positions: MatchPosition[]
32 rowOffset: number
33 currentIdx: number
34 } | null,
35 ) => void
36} {
37 useContext(StdinContext) // anchor to App subtree for hook rules
38 const ink = instances.get(process.stdout)
39 return useMemo(() => {
40 if (!ink) {
41 return {
42 setQuery: () => {},
43 scanElement: () => [],
44 setPositions: () => {},
45 }
46 }
47 return {
48 setQuery: (query: string) => ink.setSearchHighlight(query),
49 scanElement: (el: DOMElement) => ink.scanElementSubtree(el),
50 setPositions: state => ink.setSearchPositions(state),
51 }
52 }, [ink])
53}
54

Callers 1

REPLFunction · 0.85

Calls 4

setSearchHighlightMethod · 0.80
scanElementSubtreeMethod · 0.80
setSearchPositionsMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected