zed-industries/zed · error
you can't prepaint LineWithInvisibles twice
Error message
you can't prepaint LineWithInvisibles twice
What it means
A one-shot lifecycle invariant: LineWithInvisibles::prepaint computes and caches per-line layout state, and painting a line prepaints it exactly once per frame. The expect fires when the same LineWithInvisibles element is prepainted twice — usually an element was reused across two paint passes or added to two parents — indicating a framework usage bug rather than bad data.
Source
Thrown at crates/editor/src/element.rs:7542
line_elements,
window,
cx,
);
}
fn prepaint_with_custom_offset(
&mut self,
line_height: Pixels,
scroll_pixel_position: gpui::Point<ScrollPixelOffset>,
content_origin: gpui::Point<Pixels>,
line_y: Pixels,
line_elements: &mut SmallVec<[AnyElement; 1]>,
window: &mut Window,
cx: &mut App,
) {
let mut fragment_origin =
content_origin + gpui::point(Pixels::from(-scroll_pixel_position.x), line_y);
for fragment in &mut self.fragments {
match fragment {
LineFragment::Text(line) => {
fragment_origin.x += line.width;
}
LineFragment::Element { element, size, .. } => {
let mut element = element
.take()
.expect("you can't prepaint LineWithInvisibles twice");
// Center the element vertically within the line.
let mut element_origin = fragment_origin;
element_origin.y += (line_height - size.height) / 2.;
element.prepaint_at(element_origin, window, cx);
line_elements.push(element);
fragment_origin.x += size.width;
}
}View on GitHub (pinned to 9d272b0363)
Solutions
- Construct a fresh LineWithInvisibles per prepaint site instead of reusing a prepared element
- Track a 'prepainted' flag and no-op (or rebuild) on a second prepaint rather than panicking
- Audit callers that clone or re-add prepared line elements to multiple element trees
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/editor/src/element.rs:7440 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/9ce33a4058600d57.
Report an issue: GitHub.