{"record":{"id":"5ede912c1d184cdc","repo":"zed-industries/zed","slug":"missing-cursor-position-codeblock","errorCode":null,"errorMessage":"Missing cursor position codeblock","messagePattern":"Missing cursor position codeblock","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction/src/example_spec.rs","lineNumber":411,"sourceCode":"                        Section::CursorPosition => {\n                            spec.cursor_path = Path::new(block_info).into();\n                            spec.cursor_position = mem::take(&mut text);\n                        }\n                        Section::ExpectedPatch => {\n                            spec.expected_patches.push(mem::take(&mut text));\n                        }\n                        Section::RejectedPatch => {\n                            spec.rejected_patch = Some(mem::take(&mut text));\n                        }\n                        Section::Start | Section::Other => {}\n                    }\n                }\n                _ => {}\n            }\n        }\n\n        if spec.cursor_path.as_ref() == Path::new(\"\") || spec.cursor_position.is_empty() {\n            anyhow::bail!(\"Missing cursor position codeblock\");\n        }\n\n        Ok(spec)\n    }\n\n    /// Returns the excerpt of text around the cursor, and the offset of the cursor within that\n    /// excerpt.\n    ///\n    /// The cursor's position is marked with a special comment that appears\n    /// below the cursor line, which contains the string `[CURSOR_POSITION]`,\n    /// preceded by an arrow marking the cursor's column. The arrow can be\n    /// either:\n    /// - `^` - The cursor column is at the position of the `^` character (pointing up to the cursor)\n    /// - `<` - The cursor column is at the first non-whitespace character on that line.\n    pub fn cursor_excerpt(&self) -> Result<(String, usize)> {\n        let input = &self.cursor_position;\n\n        // Check for inline cursor marker first","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction/src/example_spec.rs#L393-L429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the cursor code block with the file path line and the position marker line containing `[CURSOR_POSITION]`.","Verify the block's tag is exactly what the parser expects so it lands in the cursor section rather than `Other`.","Run the spec through the parser to confirm cursor_path/cursor_position are populated."],"exampleFix":"// before — no cursor block\n## Uncommitted diff\n```diff\n+ let x = 1;\n```\n\n// after — cursor block present\n## Cursor\n```cursor\nsrc/main.rs\nlet x = 1;\n  ^ [CURSOR_POSITION]\n```","handlingStrategy":"validation","validationCode":"# require a cursor block in every spec\nfor f in examples/*.md; do grep -q '^```cursor' \"$f\" || { echo \"$f: missing cursor block\"; exit 1; }; done","typeGuard":"fn has_cursor_position(spec: &ExampleSpec) -> bool {\n    spec.cursor_path.as_ref() != Path::new(\"\") && !spec.cursor_position.is_empty()\n}","tryCatchPattern":null,"preventionTips":["Start new specs from a template that already includes the cursor block.","Run the spec parser in CI so missing cursor blocks fail the build, not the session.","Double-check block tags — a mistagged cursor block is silently classified as Other."],"tags":["edit-prediction","example-spec","validation","cursor"],"backgroundTag":"spec-validation-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}