zed-industries/zed · error

pending checkbox text must have source mappings

Error message

pending checkbox text must have source mappings

What it means

Asserts, while replacing a rendered markdown checkbox, that the pending line's source-mapping range exists so the toggle callback can be attached to the correct source span. Failure means the pending-line bookkeeping (source index/run lengths) went out of sync with the rendered runs — an internal renderer invariant break, typically after a truncation or run-splitting change.

Source

Thrown at crates/markdown/src/markdown.rs:4004

    fn pop_code_block(&mut self) {
        self.code_block_stack.pop();
    }

    fn push_link(&mut self, destination_url: SharedString, source_range: Range<usize>) {
        self.rendered_links.push(RenderedLink {
            source_range,
            destination_url,
        });
    }

    fn push_image_link(
        &mut self,
        destination_url: SharedString,
        bounds: Rc<Cell<Option<Bounds<Pixels>>>>,
    ) {
        self.rendered_image_links.push(RenderedImageLink {
            bounds,
            destination_url,
        });
    }

    fn push_footnote_ref(&mut self, label: SharedString, source_range: Range<usize>) {
        self.rendered_footnote_refs.push(RenderedFootnoteRef {
            source_range,
            label,
        });
    }

    fn push_text(&mut self, text: &str, source_range: Range<usize>) {
        self.pending_line.source_mappings.push(SourceMapping {
            rendered_index: self.pending_line.text.len(),
            source_index: source_range.start,
        });
        self.pending_line.text.push_str(text);
        self.current_source_index = source_range.end;

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Guard with Option and skip attaching the toggle callback when mappings are absent rather than panicking
  2. Add a renderer test rendering a task-list line then mutating it to keep source mappings consistent
  3. Audit pending_line truncation logic (runs.last_mut().len -= 1, current_source_index) for the desync
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/markdown/src/markdown.rs:3908 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/29eafa8a1a46bb26. Report an issue: GitHub.