Skip to main content

create_multibuffer_view

Function create_multibuffer_view 

Source
pub fn create_multibuffer_view(
    activator: &mut dyn ModeActivator,
    sources: HashMap<BufferId, Arc<dyn Document>>,
    excerpts: Vec<Excerpt>,
    name: Option<String>,
    flags: BufferFlags,
    registry: CommandRegistryHandle,
    lang_registry: Option<Arc<LangRegistry>>,
    fold_grouping: FoldGrouping,
) -> BufferId
Expand description

Atomic insert + activate-major for a multibuffer view. Returns the freshly-allocated view BufferId. After this call:

  • The view buffer exists in BufferRegistry (as a BufferData::Multibuffer entry).
  • MultibufferRegistry::handle(buffer_id) returns the typed handle.
  • multibuffer-mode is the active major on the buffer.

The caller (typically a provider’s public trigger function, e.g. project_search) is responsible for activating its own provider-minor mode after this returns (see §3.7 worked example).

Empty sources + empty excerpts are valid. Async providers (project-search, lsp-references, etc.) call this with empty inputs to open the view immediately, then stream content in via MultibufferDocumentHandle::append_excerpts as their scan progresses.

Missing services log + return a fresh BufferId — the caller can detect by checking activator.services().get::<MultibufferRegistryHandle>() .and_then(|r| r.handle(id)) returning Some. Production boot wires both services unconditionally; failure here means boot order is broken.