zed-industries/zed · error · anyhow::Error
invalid transformation range
Error message
invalid transformation range
What it means
Building the inline-assist request (tool-streaming variant, `build_request_tools`), the selected range's start and end points are mapped through `point_to_buffer_offset` on a multi-buffer snapshot. Both resolve, but into different underlying buffers (`start_buffer.remote_id() != end_buffer.remote_id()`), so there is no single buffer to transform and the request is rejected.
Solutions
- Restrict the selection to a single file/excerpt and re-run the inline transformation.
- Open the specific file in its own editor buffer (not the multi-buffer) and select there.
- Run the transformation per file with one range each instead of one cross-file range.
- In code building on these crates, pre-check both endpoints resolve to the same `remote_id` before building the request.
Example fix
// caller-side guard, before building the request
// before
let request = transformation.build_request_tools(model, prompt, ctx, cx)?;
// after
let snapshot = buffer.read(cx).snapshot(cx);
let ok = snapshot.point_to_buffer_offset(range.start)
.zip(snapshot.point_to_buffer_offset(range.end))
.map(|(s, e)| s.0.remote_id() == e.0.remote_id())
.unwrap_or(false);
if !ok {
return anyhow::bail!("select within a single file");
}
let request = transformation.build_request_tools(model, prompt, ctx, cx)?; Defensive patterns
Strategy: type-guard
Validate before calling
let snapshot = buffer.read(cx).snapshot(cx);
if let (Some((sb, _)), Some((eb, _))) = (
snapshot.point_to_buffer_offset(range.start),
snapshot.point_to_buffer_offset(range.end),
) {
if sb.remote_id() != eb.remote_id() {
// cross-file selection: reject before building the inline-assist request
}
} Type guard
fn range_in_single_buffer(
snapshot: &MultiBufferSnapshot,
range: Range<Point>,
) -> bool {
match (snapshot.point_to_buffer_offset(range.start), snapshot.point_to_buffer_offset(range.end)) {
(Some((sb, _)), Some((eb, _))) => sb.remote_id() == eb.remote_id(),
_ => false,
}
} Try / catch
match codegen.build_request_tools(model, prompt, ctx, cx) {
Err(e) if e.to_string() == "invalid transformation range" => {
// ask the user to re-select within one file, then retry
}
rest => rest,
} Prevention
- Run inline assist from a single-file editor, not a multi-buffer view.
- Check both endpoints map to the same buffer before showing inline-assist UI.
- Split cross-file edits into one invocation per file.
When it happens
Trigger: Invoking inline transformation (edit/transform selection) with a selection spanning two excerpts of a multi-buffer — e.g. a search-results buffer or a project search tab where the selection crosses from one file's excerpt into another.
Common situations: Select-all in a multi-buffer view then triggering inline assist; a selection that starts at the end of one file's excerpt and extends into the next; project-wide search buffers holding results from multiple files.
Related errors
- not supported
- anchor's path was never added to multibuffer
- auto_compact threshold of 0 is not valid
- blocking sender returned without value
- Cannot list directory because its path matches the user's…
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/c7508e0de52359f7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent_ui/src/buffer_codegen.rs:484
if Arc::ptr_eq(language, &language::PLAIN_TEXT) {
None
} else {
Some(language.name())
}
} else {
None
};
let language_name = language_name.as_ref();
let start = buffer.point_to_buffer_offset(self.range.start);
let end = buffer.point_to_buffer_offset(self.range.end);
let (buffer, range) = if let Some((start, end)) = start.zip(end) {
let (start_buffer, start_buffer_offset) = start;
let (end_buffer, end_buffer_offset) = end;
if start_buffer.remote_id() == end_buffer.remote_id() {
(start_buffer.clone(), start_buffer_offset..end_buffer_offset)
} else {
anyhow::bail!("invalid transformation range");
}
} else {
anyhow::bail!("invalid transformation range");
};
let system_prompt = self
.builder
.generate_inline_transformation_prompt_tools(
language_name,
buffer,
range.start.0..range.end.0,
)
.context("generating content prompt")?;
let temperature = AgentSettings::temperature_for_model(model, cx);
let session_id = self.session_id.to_string();
let tool_choice = modelView on GitHub (pinned to 916fc2b8cb)