zed-industries/zed · error
relative marker maps before first marker
Error message
relative marker maps before first marker
What it means
In the v0317 relative-marker scheme, the cursor's anchor block index plus the model-supplied negative delta resolved to an index before the first marker (below zero), so the start boundary would fall outside the editable region.
Source
Thrown at crates/zeta_prompt/src/multi_region.rs:841
.context("end marker number out of range")?;
Ok((start_byte, end_byte))
})
}
pub fn apply_marker_span_v0317(
old_editable: &str,
output: &str,
cursor_offset_in_old: Option<usize>,
) -> Result<String> {
let tags = collect_relative_marker_tags(output);
let marker_offsets = compute_marker_offsets(old_editable);
let anchor_idx = cursor_block_index(cursor_offset_in_old, &marker_offsets);
apply_marker_span_impl(old_editable, &tags, output, |start_delta, end_delta| {
let start_idx_signed = anchor_idx as isize + start_delta;
let end_idx_signed = anchor_idx as isize + end_delta;
if start_idx_signed < 0 || end_idx_signed < 0 {
return Err(anyhow!("relative marker maps before first marker"));
}
let start_idx = usize::try_from(start_idx_signed).context("invalid start marker index")?;
let end_idx = usize::try_from(end_idx_signed).context("invalid end marker index")?;
let start_byte = *marker_offsets
.get(start_idx)
.context("start marker number out of range")?;
let end_byte = *marker_offsets
.get(end_idx)
.context("end marker number out of range")?;
Ok((start_byte, end_byte))
})
}
pub fn apply_marker_span_v0318(old_editable: &str, output: &str) -> Result<String> {
let tags = collect_marker_tags(output);
if tags.len() >= 2 {
let start_num = tags[0].value;View on GitHub (pinned to f4178619ac)
Solutions
- Clamp the resolved index to the first marker instead of erroring, if the intended span is the region start
- Reject the output and re-prompt, since the relative offset is inconsistent with the cursor anchor
- Ensure the cursor offset passed in actually lies inside the editable region's marker blocks
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/zeta_prompt/src/multi_region.rs:841 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/a68951adc68bcf79.
Report an issue: GitHub.