zed-industries/zed · error

could not locate suffix lines

Error message

could not locate suffix lines

What it means

The suffix context lines echoed by the model could not be located at a line boundary in the original text after the prefix, so the replacement end offset is unknown. The model's suffix context drifted from the actual buffer content.

Solutions

  1. Retry the request for a verbatim suffix context
  2. Use fuzzy or whitespace-insensitive suffix matching as a fallback
  3. Reject the edit when suffix context cannot be trusted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4412 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/c6afea4bef2c7220. Report an issue: GitHub.

Appendix: source

Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4412

        let (new_text, suffix_context) = rest
            .split_once("<|fim_suffix|>\n")
            .or_else(|| rest.split_once("<|fim_suffix|>"))
            .unwrap_or((rest, ""));

        let suffix_context = if prefix_context.is_empty() && !suffix_context.is_empty() {
            suffix_context.strip_prefix('\n').unwrap_or(suffix_context)
        } else {
            suffix_context
        };

        let prefix_offset = find_substring_at_line_boundary(context, prefix_context)
            .ok_or_else(|| anyhow!("could not locate prefix lines"))?
            + prefix_context.len();
        let suffix_offset = if suffix_context.is_empty() {
            context.len()
        } else {
            find_substring_at_line_boundary(&context[prefix_offset..], suffix_context)
                .ok_or_else(|| anyhow!("could not locate suffix lines"))?
                + prefix_offset
        };

        let edit_range = prefix_offset..suffix_offset;
        return Ok((edit_range, new_text.to_string()));
    }

    fn find_substring_at_line_boundary(haystack: &str, needle: &str) -> Option<usize> {
        if needle.is_empty() {
            return Some(0);
        }

        haystack.match_indices(needle).find_map(|(offset, _)| {
            let matched_line_start = offset == 0 || haystack[..offset].ends_with('\n');
            matched_line_start.then_some(offset)
        })
    }

View on GitHub (pinned to f4178619ac)