Skip to main content

Module grep_highlight

Module grep_highlight 

Source
Expand description

PH.3: concrete grep-preview highlighter.

lattice-picker defines the GrepPreviewHighlighter trait but has no lattice-syntax dependency — that absence is the structural off-thread guarantee (a picker source physically cannot parse on the render thread). The host owns lattice-syntax, so the concrete impl lives here and is injected into GrepSource at boot.

Grep hits come from arbitrary files (not the active buffer’s parsed tree), so each preview line is highlighted by selecting a grammar from the file extension and parsing the single line. The expensive part — compiling a grammar’s highlight query — is cached per language across calls (and across live-grep keystrokes), so steady state is just a short single-line parse per hit. All of this runs on the grep blocking task (GrepSource::spawn_grep), never the render thread.

See docs/dev/architecture/picker-preview-highlight.md §7.

Structs§

SyntaxGrepHighlighter
Per-language grammar cache backing the grep preview highlighter. None in the map means “this language has no registered grammar” — cached so repeated hits in an unsupported file don’t re-probe the registry. Wrapped in a Mutex because the trait is Sync and grep runs are serial within a task but may overlap across runs.