zed-industries/zed · error
shared scroll anchor references a non native display map, bu
Error message
shared scroll anchor references a non native display map, but snapshot has no companion
What it means
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.
Source
Thrown at crates/editor/src/scroll.rs:82
/// In the split diff view, the two sides share a ScrollAnchor using this struct.
/// Either side can set a ScrollAnchor that points to its own multibuffer, and we store the ID of the display map
/// that the last-written anchor came from so that we know how to resolve it to a DisplayPoint.
///
/// For normal editors, this just acts as a wrapper around a ScrollAnchor.
#[derive(Clone, Copy, Debug)]
pub struct SharedScrollAnchor {
pub scroll_anchor: ScrollAnchor,
pub display_map_id: Option<EntityId>,
}
impl SharedScrollAnchor {
pub fn scroll_position(&self, snapshot: &DisplaySnapshot) -> gpui::Point<ScrollOffset> {
let snapshot = if let Some(display_map_id) = self.display_map_id
&& display_map_id != snapshot.display_map_id
{
let companion_snapshot = snapshot
.companion_snapshot()
.expect("shared scroll anchor references a non native display map, but snapshot has no companion");
assert_eq!(
companion_snapshot.display_map_id, display_map_id,
"shared scroll anchor display map should match the snapshot's split companion"
);
companion_snapshot
} else {
snapshot
};
self.scroll_anchor.scroll_position(snapshot)
}
pub fn scroll_top_display_point(&self, snapshot: &DisplaySnapshot) -> DisplayPoint {
let snapshot = if let Some(display_map_id) = self.display_map_id
&& display_map_id != snapshot.display_map_id
{
let companion_snapshot = snapshot
.companion_snapshot()View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/editor/src/scroll.rs:82 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/af635bd6c6e74f14.
Report an issue: GitHub.