Skip to main content

Module search

Module search 

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

  1. Pulls the ProjectSearchService handle from activator.services().
  2. Opens an empty multibuffer view via create_multibuffer_view; the view auto-subscribes to source events via M.4.
  3. Seeds initial provider state (query, options, scanning).
  4. Sets the headerline to InProgress { label: "Searching" }.
  5. Activates ProjectSearchMode (this minor’s on_activate subscribes to ProjectSearchBatchReady + ProjectSearchCompleted and forwards them into MultibufferDocumentHandle::append_excerpts / set_headerline).
  6. 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§

FileHits
One file’s hits. Returned in ProjectSearchBatchReady batches.
InMemoryProjectSearchService
Default in-memory ProjectSearchService.
ProjectSearchBatchReady
ProjectSearchCompleted
ProjectSearchMode
project-search-mode — provider-minor for project-search views. Contributes ReadOnly = true in M.6.0 (wgrep-style editable results land in a follow-up).
ProjectSearchModeGuard
ProjectSearchOptions
User-supplied scan parameters.
ProjectSearchProgressUpdated
ProjectSearchRefreshed
ProjectSearchState
Per-view state owned by ProjectSearchService.
SearchContextSize
Number of context lines to show above and below each matched line in :search results. Default 0 (no context — only matched lines appear, matching the “1 line per hit, 1 header per file” UX).

Enums§

SearchStatus
Status of a scan task.

Traits§

ProjectSearchService
Per-view provider state lookup. Registered in ServiceRegistry at boot; minor mode + scan-task glue go through this trait.

Functions§

project_search
Open a project-search multibuffer view for query under options.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 ServiceRegistry construction 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 gr refresh handler (M.10.5, registered via ActionHandlerRegistry from on_activate) can respawn after cancelling the prior task.

Type Aliases§

CurrentDirHandle
Service handle for the editor’s current working directory. Registered at boot, updated by :cd. Mode-owned handlers (e.g. search gr refresh) look this up via ActionContext to re-resolve the scan root after :cd.
ProjectSearchServiceHandle