zed-industries/zed · error
you can only call set_text on editors for singleton buffers
Error message
you can only call set_text on editors for singleton buffers
What it means
A type guard on Editor::set_text: the editor's buffer is a MultiBuffer, and set_text replaces the whole contents of exactly one buffer, so it requires as_singleton() to return Some. It panics when called on an editor whose buffer is a multi-buffer (multiple files or excerpt list), because there is no single underlying buffer whose text could be wholesale replaced.
Source
Thrown at crates/editor/src/editor.rs:8744
&mut self,
transaction_id: TransactionId,
modify: impl FnOnce(&mut TransactionSelections),
) -> bool {
self.selection_history
.transaction_mut(transaction_id)
.map(modify)
.is_some()
}
pub fn toggle_focus(
workspace: &mut Workspace,
_: &actions::ToggleFocus,
window: &mut Window,
cx: &mut Context<Workspace>,
) {
let Some(item) = workspace.recent_active_item_by_type::<Self>(cx) else {
return;
};
workspace.activate_item(&item, true, true, window, cx);
}
pub fn set_gutter_hovered(&mut self, hovered: bool, cx: &mut Context<Self>) {
if hovered != self.gutter_hovered {
self.gutter_hovered = hovered;
cx.notify();
}
}
pub fn insert_blocks(
&mut self,
blocks: impl IntoIterator<Item = BlockProperties<Anchor>>,
autoscroll: Option<Autoscroll>,
cx: &mut Context<Self>,
) -> Vec<CustomBlockId> {
let blocks = self
.display_mapView on GitHub (pinned to 9d272b0363)
Solutions
- Check as_singleton() and return early, log, or assert with a debug_assert! in debug builds instead of an unconditional panic
- For multi-buffer editors, apply edits per-excerpt or clear and insert via the multi-buffer API
- Have callers route through APIs that are defined for both singleton and multi buffers
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/editor/src/editor.rs:8648 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/c7a2132d10037b77.
Report an issue: GitHub.