Skip to main content

Module SearchProvider

Module SearchProvider 

Source
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:

  1. Pattern compilation - regex is compiled with case/word/multiline modifiers; plain-text queries are regex::escaped first.
  2. Parallel walking - workspace files are walked via WalkBuilder::build_parallel(), respecting .gitignore and .ignore files automatically.
  3. Per-file search - each file is searched individually using a Sink pattern (PerFileSink).
  4. Result aggregation - matches are collected in a shared Arc<Mutex<Vec<FileMatch>>>.

§Search features

  • Case sensitivity - controlled by isCaseSensitive option
  • Word matching - controlled by isWordMatch option
  • 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 URI
  • lineNumber - 1-based line number
  • preview - 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’s ISearchRange)

§VS Code reference

  • vs/workbench/contrib/search/browser/searchWidget.ts
  • vs/platform/search/common/search.ts
  • vs/platform/search/common/fileSearch.ts

Structs§

ColumnRange 🔒
Per-match column range within the preview line.
FileMatch 🔒
PerFileSink 🔒
TextMatch 🔒
TextSearchQuery 🔒
Mirrors VS Code’s ITextSearchQuery shape (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 the search:textSearch call.