zed-industries/zed · error

Missing cursor position codeblock

Error message

Missing cursor position codeblock

What it means

Post-parse validation of an edit-prediction example spec: after consuming the whole markdown, `spec.cursor_path` must be non-empty and `spec.cursor_position` must have content — both come only from the `cursor` code block; if it is missing (or empty) the spec is rejected (example_spec.rs:411). Every spec must state where the cursor starts.

Source

Thrown at crates/edit_prediction/src/example_spec.rs:411

                        Section::CursorPosition => {
                            spec.cursor_path = Path::new(block_info).into();
                            spec.cursor_position = mem::take(&mut text);
                        }
                        Section::ExpectedPatch => {
                            spec.expected_patches.push(mem::take(&mut text));
                        }
                        Section::RejectedPatch => {
                            spec.rejected_patch = Some(mem::take(&mut text));
                        }
                        Section::Start | Section::Other => {}
                    }
                }
                _ => {}
            }
        }

        if spec.cursor_path.as_ref() == Path::new("") || spec.cursor_position.is_empty() {
            anyhow::bail!("Missing cursor position codeblock");
        }

        Ok(spec)
    }

    /// Returns the excerpt of text around the cursor, and the offset of the cursor within that
    /// excerpt.
    ///
    /// The cursor's position is marked with a special comment that appears
    /// below the cursor line, which contains the string `[CURSOR_POSITION]`,
    /// preceded by an arrow marking the cursor's column. The arrow can be
    /// either:
    /// - `^` - The cursor column is at the position of the `^` character (pointing up to the cursor)
    /// - `<` - The cursor column is at the first non-whitespace character on that line.
    pub fn cursor_excerpt(&self) -> Result<(String, usize)> {
        let input = &self.cursor_position;

        // Check for inline cursor marker first

View on GitHub (pinned to f4178619ac)

Solutions

  1. Add the cursor code block with the file path line and the position marker line containing `[CURSOR_POSITION]`.
  2. Verify the block's tag is exactly what the parser expects so it lands in the cursor section rather than `Other`.
  3. Run the spec through the parser to confirm cursor_path/cursor_position are populated.

Example fix

// before — no cursor block
## Uncommitted diff
```diff
+ let x = 1;
```

// after — cursor block present
## Cursor
```cursor
src/main.rs
let x = 1;
  ^ [CURSOR_POSITION]
```
Defensive patterns

Strategy: validation

Validate before calling

# require a cursor block in every spec
for f in examples/*.md; do grep -q '^```cursor' "$f" || { echo "$f: missing cursor block"; exit 1; }; done

Type guard

fn has_cursor_position(spec: &ExampleSpec) -> bool {
    spec.cursor_path.as_ref() != Path::new("") && !spec.cursor_position.is_empty()
}

Prevention

When it happens

Trigger: Authoring a spec markdown without a `cursor` section, with an empty cursor block, or with a block tagged in a way the parser does not map to the cursor section, so path/position stay default/empty at EOF.

Common situations: New spec files drafted from scratch; sections deleted while editing; tag typos causing the cursor block to be classified as `Section::Other` and silently ignored.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/5ede912c1d184cdc. Report an issue: GitHub.