Expand description
M.6 (2026-06-01): SearchProvider — the worked
MultibufferProvider example.
Architecture: multibuffer-views.md §3.7 “Worked example —
SearchProvider end-to-end”. User runs :search "TODO"; the
provider:
- Pulls the
ProjectSearchServicehandle fromactivator.services(). - Opens an empty multibuffer view via
create_multibuffer_view; the view auto-subscribes to source events via M.4. - Seeds initial provider state (query, options, scanning).
- Sets the headerline to
InProgress { label: "Searching" }. - Activates
ProjectSearchMode(this minor’son_activatesubscribes toProjectSearchBatchReady+ProjectSearchCompletedand forwards them intoMultibufferDocumentHandle::append_excerpts/set_headerline). - Spawns the async scan task via the service.
The scan task runs on tokio worker threads (never the UI
thread, per paramount goal #1) — walks the project tree via
ignore::Walk, matches literal queries against each file,
batches hits, publishes ProjectSearchBatchReady events.
Structs§
- File
Hits - One file’s hits. Returned in
ProjectSearchBatchReadybatches. - InMemory
Project Search Service - Default in-memory
ProjectSearchService. - Project
Search Batch Ready - Project
Search Completed - Project
Search Mode project-search-mode— provider-minor for project-search views. ContributesReadOnly = truein M.6.0 (wgrep-style editable results land in a follow-up).- Project
Search Mode Guard - Project
Search Options - User-supplied scan parameters.
- Project
Search Progress Updated - Project
Search Refreshed - Project
Search State - Per-view state owned by
ProjectSearchService. - Search
Context Size - Number of context lines to show above and below each
matched line in
:searchresults. Default0(no context — only matched lines appear, matching the “1 line per hit, 1 header per file” UX).
Enums§
- Search
Status - Status of a scan task.
Traits§
- Project
Search Service - Per-view provider state lookup. Registered in
ServiceRegistryat boot; minor mode + scan-task glue go through this trait.
Functions§
- project_
search - Open a project-search multibuffer view for
queryunderoptions.root. Returns the view’s BufferId immediately; scan runs on a spawned tokio task and streams results via typed events. - register_
project_ search - Convenience wrapper that calls both helpers. Useful for tests that wire mode + service together; production boot uses the split helpers.
- register_
project_ search_ mode - M.6 boot helper — register the provider-minor mode. Mode registry is constructed before services in the host’s boot path, so the two registrations are split for ordering flexibility.
- register_
project_ search_ service - M.6 boot helper — register the service handle. Call in the
host’s
ServiceRegistryconstruction block. - register_
search_ ex_ command - K.2.5 (2026-06-02): register the
:search <query>ex-command. - spawn_
scan_ task - Public so the mode’s
grrefresh handler (M.10.5, registered viaActionHandlerRegistryfromon_activate) can respawn after cancelling the prior task.
Type Aliases§
- Current
DirHandle - Service handle for the editor’s current working directory.
Registered at boot, updated by
:cd. Mode-owned handlers (e.g. searchgrrefresh) look this up viaActionContextto re-resolve the scan root after:cd. - Project
Search Service Handle