{"record":{"id":"af635bd6c6e74f14","repo":"zed-industries/zed","slug":"shared-scroll-anchor-references-a-non-native-displ","errorCode":null,"errorMessage":"shared scroll anchor references a non native display map, but snapshot has no companion","messagePattern":"shared scroll anchor references a non native display map, but snapshot has no companion","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/scroll.rs","lineNumber":82,"sourceCode":"/// In the split diff view, the two sides share a ScrollAnchor using this struct.\n/// Either side can set a ScrollAnchor that points to its own multibuffer, and we store the ID of the display map\n/// that the last-written anchor came from so that we know how to resolve it to a DisplayPoint.\n///\n/// For normal editors, this just acts as a wrapper around a ScrollAnchor.\n#[derive(Clone, Copy, Debug)]\npub struct SharedScrollAnchor {\n    pub scroll_anchor: ScrollAnchor,\n    pub display_map_id: Option<EntityId>,\n}\n\nimpl SharedScrollAnchor {\n    pub fn scroll_position(&self, snapshot: &DisplaySnapshot) -> gpui::Point<ScrollOffset> {\n        let snapshot = if let Some(display_map_id) = self.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 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 snapshot's split companion\"\n            );\n            companion_snapshot\n        } else {\n            snapshot\n        };\n\n        self.scroll_anchor.scroll_position(snapshot)\n    }\n\n    pub fn scroll_top_display_point(&self, snapshot: &DisplaySnapshot) -> DisplayPoint {\n        let snapshot = if let Some(display_map_id) = self.display_map_id\n            && display_map_id != snapshot.display_map_id\n        {\n            let companion_snapshot = snapshot\n                .companion_snapshot()","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/scroll.rs#L64-L100","documentation":"A state-mismatch guard in SharedScrollAnchor::scroll_position: in the split diff view both sides share one anchor plus the display-map id it was written from. Resolving the scroll position for a non-native snapshot requires translating through that snapshot's companion map; the expect fires when the anchor references a non-native display map but the provided snapshot has no companion — i.e. the anchor's display_map_id and the snapshot's map identity disagree, so there is no valid translation path.","triggerScenarios":"Thrown at crates/editor/src/scroll.rs:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fall back to treating the anchor as native (or returning the snapshot's own scroll position) when no companion exists instead of panicking","Clear or re-baseline the shared anchor when either diff side is rebuilt or its map id changes","Add a debug assertion comparing display_map_id to snapshot ids before translation to catch divergence early"],"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-14T00:17:10.932Z"}