{"record":{"id":"130c4ebcbc668b73","repo":"zed-industries/zed","slug":"buffer-should-exist-in-multibuffer","errorCode":null,"errorMessage":"buffer should exist in multibuffer","messagePattern":"buffer should exist in multibuffer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/split.rs","lineNumber":382,"sourceCode":"    result\n}\n\nfn patch_for_excerpt(\n    source_snapshot: &MultiBufferSnapshot,\n    target_snapshot: &MultiBufferSnapshot,\n    source_buffer_snapshot: &language::BufferSnapshot,\n    target_buffer_snapshot: &language::BufferSnapshot,\n    source_excerpt_range: ExcerptRange<text::Anchor>,\n    target_excerpt_range: ExcerptRange<text::Anchor>,\n    patch: &Patch<Point>,\n    source_edited_range: Range<Point>,\n) -> CompanionExcerptPatch {\n    let source_buffer_range = source_excerpt_range\n        .context\n        .to_point(source_buffer_snapshot);\n    let source_multibuffer_range = (source_snapshot\n        .anchor_in_buffer(source_excerpt_range.context.start)\n        .expect(\"buffer should exist in multibuffer\")\n        ..source_snapshot\n            .anchor_in_buffer(source_excerpt_range.context.end)\n            .expect(\"buffer should exist in multibuffer\"))\n        .to_point(source_snapshot);\n    let target_buffer_range = target_excerpt_range\n        .context\n        .to_point(target_buffer_snapshot);\n    let target_multibuffer_range = (target_snapshot\n        .anchor_in_buffer(target_excerpt_range.context.start)\n        .expect(\"buffer should exist in multibuffer\")\n        ..target_snapshot\n            .anchor_in_buffer(target_excerpt_range.context.end)\n            .expect(\"buffer should exist in multibuffer\"))\n        .to_point(target_snapshot);\n\n    let edits = patch\n        .edits()\n        .iter()","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/split.rs#L364-L400","documentation":"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.","triggerScenarios":"Thrown at crates/editor/src/split.rs:382 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}