zed-industries/zed · error
display point out of range
Error message
display point out of range
What it means
An internal invariant guard in FoldPoint::to_offset: converting a FoldPoint to a FoldOffset queries the fold map's transform summary and panics if the given display point lies beyond the map's extent. In practice this means the point was computed against a different (stale or newer) snapshot than the one passed in, or a caller passed an unclamped end-of-buffer point; the fold map only covers rows/folds present in this snapshot.
Source
Thrown at crates/editor/src/display_map/fold_map.rs:147
#[ztracing::instrument(skip_all)]
pub fn to_inlay_point(self, snapshot: &FoldSnapshot) -> InlayPoint {
let (start, _, _) = snapshot
.transforms
.find::<Dimensions<FoldPoint, InlayPoint>, _>((), &self, Bias::Right);
let overshoot = self.0 - start.0.0;
InlayPoint(start.1.0 + overshoot)
}
#[ztracing::instrument(skip_all)]
pub fn to_offset(self, snapshot: &FoldSnapshot) -> FoldOffset {
let (start, _, item) = snapshot
.transforms
.find::<Dimensions<FoldPoint, TransformSummary>, _>((), &self, Bias::Right);
let overshoot = self.0 - start.1.output.lines;
let mut offset = start.1.output.len;
if !overshoot.is_zero() {
let transform = item.expect("display point out of range");
assert!(transform.placeholder.is_none());
let end_inlay_offset = snapshot
.inlay_snapshot
.to_offset(InlayPoint(start.1.input.lines + overshoot));
offset += end_inlay_offset.0 - start.1.input.len;
}
FoldOffset(offset)
}
}
impl<'a> sum_tree::Dimension<'a, TransformSummary> for FoldPoint {
fn zero(_cx: ()) -> Self {
Default::default()
}
fn add_summary(&mut self, summary: &'a TransformSummary, _: ()) {
self.0 += &summary.output.lines;
}View on GitHub (pinned to f4178619ac)
Solutions
- Clamp the FoldPoint to snapshot.max_point()/extent before converting
- Ensure points and snapshots are taken from the same display map revision — never mix a point from one snapshot with another
- In callers like chunks_at/chars_at, operate on the snapshot the point was derived from, or re-anchor the point first
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/editor/src/display_map/fold_map.rs:147 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/06bb249a9ec30f62.
Report an issue: GitHub.