{"record":{"id":"576f1c0a0fd98acb","repo":"zed-industries/zed","slug":"shared-scroll-anchor-references-a-non-native-displ-576f1c","errorCode":null,"errorMessage":"shared scroll anchor references a non native display map, but the snapshot has no companion","messagePattern":"shared scroll anchor references a non native display map, but the snapshot has no companion","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/scroll.rs","lineNumber":242,"sourceCode":"        }\n        offset\n    }\n\n    /// Get a ScrollAnchor whose `anchor` field is guaranteed to point into the multibuffer for the provided snapshot.\n    ///\n    /// For normal editors, this just retrieves the internal ScrollAnchor and is lossless. When the editor is part of a split diff,\n    /// we may need to translate the anchor to point to the \"native\" multibuffer first. That translation is lossy,\n    /// so this method should be used sparingly---if you just need a scroll position or display point, call the appropriate helper method instead,\n    /// since they can losslessly handle the case where the ScrollAnchor was last set from the other side.\n    pub fn native_anchor(&self, snapshot: &DisplaySnapshot, cx: &App) -> ScrollAnchor {\n        let shared = self.anchor.read(cx);\n\n        let mut result = if let Some(display_map_id) = shared.display_map_id\n            && display_map_id != snapshot.display_map_id\n        {\n            let companion_snapshot = snapshot\n                .companion_snapshot()\n                .expect(\"shared scroll anchor references a non native display map, but the snapshot has no companion\");\n            assert_eq!(\n                companion_snapshot.display_map_id, display_map_id,\n                \"shared scroll anchor display map should match the companion used for native anchor conversion\"\n            );\n\n            let mut display_point = shared\n                .scroll_anchor\n                .anchor\n                .to_display_point(companion_snapshot);\n            *display_point.column_mut() = 0;\n            let buffer_point = snapshot.display_point_to_point(display_point, Bias::Left);\n            let anchor = snapshot.buffer_snapshot().anchor_before(buffer_point);\n            ScrollAnchor {\n                anchor,\n                offset: shared.scroll_anchor.offset,\n            }\n        } else {\n            shared.scroll_anchor","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/scroll.rs#L224-L260","documentation":"The same shared-anchor invariant, hit from native_anchor: converting the stored ScrollAnchor to one pointing at the provided snapshot's native multibuffer requires the snapshot's companion when the anchor was written by the other (non-native) side of a split diff. The expect fires when the recorded display_map_id names a non-native map but the given snapshot carries no companion multibuffer — the two sides' display maps are no longer paired, making the lossy translation impossible.","triggerScenarios":"Thrown at crates/editor/src/scroll.rs:242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return the raw anchor unchanged when the companion needed for translation is missing, documenting that the result may be approximate","Invalidate/reset the SharedScrollAnchor whenever a diff side's display map is recreated without a companion","Track companion availability alongside display_map_id so mismatches are detectable before translation"],"exampleFix":null,"handlingStrategy":"fallback","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"}