Skip to main content

Module file_search

Module file_search 

Source
Expand description

@-triggered fuzzy file picker for the composer (grok-build parity).

Detects @ at a word boundary in the input buffer, opens a fuzzy file-search dropdown above the composer, and inserts the selected path (optionally with a line range) back into the buffer as plain text.

Design (Option B from the plan): the input buffer stays a plain String. @path:N-M references are inserted as text; the agent’s read tool already parses path + line-range from text. No chip model, no forked TextArea — the dropdown is the only new UI surface.

Structs§

AtToken
The parsed @-reference at the cursor position, if any. Returned by parse_at_cursor — a pure function with no I/O, fully unit-testable.
FileSearchResult
One fuzzy-matched file result.
FileSearchState
State for the active file-search dropdown. Stored in RenderState.file_search while the picker is open.

Constants§

MAX_RESULTS
Maximum number of results to show in the dropdown.

Functions§

build_index
Walk the workspace and build a file index. Respects .gitignore, .git/info/exclude, and the global gitignore. Hidden files (dotfiles) are excluded by default and toggled on via the @! gesture.
insertion_text
Build the text to insert into the buffer when the user accepts a result.
open
Open a new file-search state at the given @ offset, building the workspace index. Called from the input thread when @ is first detected.
parse_at_cursor
Detect an @-file-reference trigger at the cursor position.
search
Fuzzy-filter index by query, returning ranked results.