zed-industries/zed · error

A multi buffer in prompt isn't possible

Error message

A multi buffer in prompt isn't possible

What it means

A type guard in the prompt editor's confirm handler: submitting a prompt reads the prompt entity's buffer and calls as_singleton().expect, because prompt inputs are modeled as a single buffer and a multi-buffer (excerpt list) prompt buffer would make the submitted message ambiguous. It fires only if a prompt was somehow constructed from a multi-buffer, which the API contract forbids.

Source

Thrown at crates/editor/src/editor.rs:12610

    fn set_masked(&self, masked: bool, _window: &mut Window, cx: &mut App) {
        self.0.update(cx, |editor, cx| {
            editor.set_masked(masked, cx);
        });
    }

    fn set_read_only(&self, read_only: bool, cx: &mut App) {
        self.0.update(cx, |editor, cx| {
            editor.set_read_only(read_only);
            cx.notify();
        });
    }
}
impl<T> Default for InvalidationStack<T> {
    fn default() -> Self {
        Self(Default::default())
    }
}

impl<T> Deref for InvalidationStack<T> {
    type Target = Vec<T>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl<T> DerefMut for InvalidationStack<T> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl InvalidationRegion for SnippetState {
    fn ranges(&self) -> &[Range<Anchor>] {
        &self.ranges[self.active_index]
    }

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Guard with if let Some(buffer) = ...as_singleton() and skip or no-op the confirm when the invariant is broken
  2. Enforce single-buffer construction at prompt-builder time so confirm can rely on it
  3. Replace expect with a debug_assert plus graceful degradation in release builds
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/editor/src/editor.rs:12474 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/5f1107ba56e9802c. Report an issue: GitHub.