{"record":{"id":"efa36285e71b194f","repo":"zed-industries/zed","slug":"cursor-position-marker-line-must-contain-or","errorCode":null,"errorMessage":"cursor position marker line must contain '^' or '<' before [CURSOR_POSITION]","messagePattern":"cursor position marker line must contain '\\^' or '<' before \\[CURSOR_POSITION\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction/src/example_spec.rs","lineNumber":456,"sourceCode":"            .context(\"missing [CURSOR_POSITION] marker\")?;\n        let marker_line_start = input[..marker_offset]\n            .rfind('\\n')\n            .map(|pos| pos + 1)\n            .unwrap_or(0);\n        let marker_line_end = input[marker_line_start..]\n            .find('\\n')\n            .map(|pos| marker_line_start + pos + 1)\n            .unwrap_or(input.len());\n        let marker_line = &input[marker_line_start..marker_line_end].trim_end_matches('\\n');\n\n        let cursor_column = if let Some(cursor_offset) = marker_line.find('^') {\n            cursor_offset\n        } else if let Some(less_than_pos) = marker_line.find('<') {\n            marker_line\n                .find(|c: char| !c.is_whitespace())\n                .unwrap_or(less_than_pos)\n        } else {\n            anyhow::bail!(\n                \"cursor position marker line must contain '^' or '<' before [CURSOR_POSITION]\"\n            );\n        };\n\n        let mut excerpt = input[..marker_line_start].to_string() + &input[marker_line_end..];\n        excerpt.truncate(excerpt.trim_end_matches('\\n').len());\n\n        // The cursor is on the line above the marker line.\n        let cursor_line_end = marker_line_start.saturating_sub(1);\n        let cursor_line_start = excerpt[..cursor_line_end]\n            .rfind('\\n')\n            .map(|pos| pos + 1)\n            .unwrap_or(0);\n        let cursor_offset = cursor_line_start + cursor_column;\n\n        Ok((excerpt, cursor_offset))\n    }\n","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction/src/example_spec.rs#L438-L474","documentation":"Cursor-extraction in example specs: the marker line is the line containing `[CURSOR_POSITION]`; the column is taken from a `^` under the target column, or from the first non-whitespace char when `<` is used; if the marker line contains neither `^` nor `<` before the marker there is no way to compute the column and the parser bails (example_spec.rs:456).","triggerScenarios":"A cursor block whose marker line is only `[CURSOR_POSITION]`, or uses a different caret character ( `~`, `|` ), or where the arrow was deleted while editing the spec.","commonSituations":"Hand-editing marker lines; copy-paste that drops the caret; specs written without reading the marker convention (`^` points at the column, `<` marks a position left of code).","solutions":["Put `^` in the marker line at the exact column under the target character: `  ^ [CURSOR_POSITION]`.","Or use `<` when marking before code text — the first non-whitespace char after `<` sets the column.","Keep the marker line directly below the cursor line; do not remove the arrow character."],"exampleFix":"```cursor\nsrc/main.rs\nlet value = compute(x);\n[CURSOR_POSITION]        // before — no ^ or < on the marker line\n```\n\n```cursor\nsrc/main.rs\nlet value = compute(x);\n            ^ [CURSOR_POSITION]   // after — caret under the target column\n```","handlingStrategy":"validation","validationCode":"// check the marker line shape before parsing specs\nlet marker = line_containing(spec_text, \"[CURSOR_POSITION]\");\nif !marker.contains('^') && !marker.contains('<') {\n    return Err(anyhow!(\"marker line needs ^ or < before [CURSOR_POSITION]\"));\n}","typeGuard":"fn is_valid_marker_line(line: &str) -> bool {\n    line.contains(\"[CURSOR_POSITION]\") && (line.contains('^') || line.contains('<'))\n}","tryCatchPattern":null,"preventionTips":["Copy the marker convention (`  ^ [CURSOR_POSITION]`) from an existing spec rather than retyping it.","Validate marker lines with a lint in CI.","Never edit away the caret when trimming whitespace in specs."],"tags":["edit-prediction","example-spec","cursor","parsing"],"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-14T05:17:10.506Z"}