Expand description
SearchProvider: runs workspace-wide text and symbol searches.
§SearchProvider (Environment)
Implements the SearchProvider trait using the grep-searcher crate
(the ripgrep library) for MountainEnvironment.
§Search architecture
The search implementation uses a multi-threaded approach:
- Pattern compilation - regex is compiled with case/word/multiline
modifiers; plain-text queries are
regex::escaped first. - Parallel walking - workspace files are walked via
WalkBuilder::build_parallel(), respecting.gitignoreand.ignorefiles automatically. - Per-file search - each file is searched individually using a
Sinkpattern (PerFileSink). - Result aggregation - matches are collected in a shared
Arc<Mutex<Vec<FileMatch>>>.
§Search features
- Case sensitivity - controlled by
isCaseSensitiveoption - Word matching - controlled by
isWordMatchoption - Regex support - full regex via
grep-regex - Ignore files - respects
.gitignore,.ignore, and siblings - Memory efficient - streams results; never loads entire files
§Search result format
Each match includes:
resource- file URIlineNumber- 1-based line numberpreview- matched text line (capped at 512 bytes)columns- per-match{start, end}char-offset ranges (0-based, UTF-8 code units to match VS Code’sISearchRange)
§VS Code reference
vs/workbench/contrib/search/browser/searchWidget.tsvs/platform/search/common/search.tsvs/platform/search/common/fileSearch.ts
Structs§
- Column
Range 🔒 - Per-match column range within the preview line.
- File
Match 🔒 - PerFile
Sink 🔒 - Text
Match 🔒 - Text
Search 🔒Query - Mirrors VS Code’s
ITextSearchQueryshape (vs/workbench/services/ search/common/search.ts). The workbench’s Search view serialises the user’s input into this struct and the ProxyChannel sends it as slot 0 of thesearch:textSearchcall.