zed-industries/zed · error
buffer should exist in multibuffer
Error message
buffer should exist in multibuffer
What it means
A cross-snapshot invariant guard in patch_for_excerpt: while computing companion excerpt patches for a split edit, it looks up the excerpt's buffer within the multibuffer snapshots and expects to find it ('buffer should exist in multibuffer'). It fires when a buffer present in one snapshot (or the excerpt list) is absent from the other — typically because the two MultiBufferSnapshots were taken at different revisions and an excerpt was added or removed in between.
Source
Thrown at crates/editor/src/split.rs:382
result
}
fn patch_for_excerpt(
source_snapshot: &MultiBufferSnapshot,
target_snapshot: &MultiBufferSnapshot,
source_buffer_snapshot: &language::BufferSnapshot,
target_buffer_snapshot: &language::BufferSnapshot,
source_excerpt_range: ExcerptRange<text::Anchor>,
target_excerpt_range: ExcerptRange<text::Anchor>,
patch: &Patch<Point>,
source_edited_range: Range<Point>,
) -> CompanionExcerptPatch {
let source_buffer_range = source_excerpt_range
.context
.to_point(source_buffer_snapshot);
let source_multibuffer_range = (source_snapshot
.anchor_in_buffer(source_excerpt_range.context.start)
.expect("buffer should exist in multibuffer")
..source_snapshot
.anchor_in_buffer(source_excerpt_range.context.end)
.expect("buffer should exist in multibuffer"))
.to_point(source_snapshot);
let target_buffer_range = target_excerpt_range
.context
.to_point(target_buffer_snapshot);
let target_multibuffer_range = (target_snapshot
.anchor_in_buffer(target_excerpt_range.context.start)
.expect("buffer should exist in multibuffer")
..target_snapshot
.anchor_in_buffer(target_excerpt_range.context.end)
.expect("buffer should exist in multibuffer"))
.to_point(target_snapshot);
let edits = patch
.edits()
.iter()View on GitHub (pinned to f4178619ac)
Solutions
- Skip patch generation (return None) for excerpts whose buffer is missing from either snapshot instead of panicking
- Ensure source and target snapshots are captured from the same multibuffer revision (snapshot them together, or re-snapshot on mismatch)
- Assert excerpt/buffer set equality between the two snapshots before iterating, failing softly on divergence
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/editor/src/split.rs:382 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/130c4ebcbc668b73.
Report an issue: GitHub.