zed-industries/zed · error

not supported

Error message

not supported

What it means

When multibuffer APIs convert a caller-supplied range to offsets (excerpt boundaries and offset math), the start bound must be Included or Unbounded. Rust has no exclusive-start range syntax, but callers can construct one manually with (Bound::Excluded(x), ...). That form is explicitly rejected here and panics with 'not supported'.

Solutions

  1. Normalize the start bound before calling: convert Excluded(o) to Included(o + 1) for discrete offsets
  2. Otherwise only pass Included or Unbounded start bounds to these APIs
  3. Centralize range construction in one helper that clamps/normalizes bounds for every caller

Example fix

// before
let bounds = (Bound::Excluded(start), Bound::Included(end));
let boundaries = snapshot.excerpt_boundaries((bounds.0, bounds.1)); // panics

// after: normalize the start bound
let start_bound = match bounds.0 {
    Bound::Excluded(offset) => Bound::Included(offset + 1),
    bound => bound,
};
let boundaries = snapshot.excerpt_boundaries((start_bound, bounds.1));
Defensive patterns

Strategy: validation

Validate before calling

// normalize the start bound before calling range APIs
fn normalize_start<T>(bound: Bound<T>, next: impl Fn(T) -> T) -> Bound<T> {
    match bound {
        Bound::Excluded(value) => Bound::Included(next(value)),
        bound => bound,
    }
}

let start = normalize_start((start, end).0, |offset| offset + 1);

Prevention

When it happens

Trigger: Passing a bound pair whose start is Bound::Excluded - e.g. (Bound::Excluded(start), Bound::Included(end)) built by generic range-manipulation code - into multibuffer range APIs such as excerpt_boundaries that convert the start bound to an offset.

Common situations: Generic adapters that translate user ranges, regex matches, or interval-arithmetic results into Bound pairs and forward them; code ported from other containers that accept exclusive starts; hand-built ranges in tests.

Related errors


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

Appendix: source

Thrown at crates/multi_buffer/src/multi_buffer.rs:5484

        if !ranges_are_ordered {
            return text_anchor_ranges
                .into_iter()
                .map(|range| self.buffer_anchor_range_to_anchor_range(range))
                .collect();
        }

        let path_key = buffer_state.path_key.clone();
        let mut cursor = self.excerpts.cursor::<PathKey>(());
        cursor.seek_forward(&path_key, Bias::Left);
        let excerpts = iter::from_fn(move || {
            let excerpt = cursor.item()?;
            if excerpt.path_key != path_key {
                return None;
            }
            cursor.next();
            Some(excerpt)
        })
        .collect::<Vec<_>>();
        let mut first_candidate_index = 0;
        text_anchor_ranges
            .into_iter()
            .map(|range| {
                while let Some(excerpt) = excerpts.get(first_candidate_index) {
                    let buffer_snapshot = excerpt.buffer_snapshot(self);
                    if excerpt
                        .range
                        .context
                        .end
                        .cmp(&range.start, buffer_snapshot)
                        .is_lt()
                    {
                        first_candidate_index += 1;
                        continue;
                    }
                    break;
                }

View on GitHub (pinned to 916fc2b8cb)