{"record":{"id":"c7a2132d10037b77","repo":"zed-industries/zed","slug":"you-can-only-call-set-text-on-editors-for-singleto","errorCode":null,"errorMessage":"you can only call set_text on editors for singleton buffers","messagePattern":"you can only call set_text on editors for singleton buffers","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/editor.rs","lineNumber":8744,"sourceCode":"        &mut self,\n        transaction_id: TransactionId,\n        modify: impl FnOnce(&mut TransactionSelections),\n    ) -> bool {\n        self.selection_history\n            .transaction_mut(transaction_id)\n            .map(modify)\n            .is_some()\n    }\n\n    pub fn toggle_focus(\n        workspace: &mut Workspace,\n        _: &actions::ToggleFocus,\n        window: &mut Window,\n        cx: &mut Context<Workspace>,\n    ) {\n        let Some(item) = workspace.recent_active_item_by_type::<Self>(cx) else {\n            return;\n        };\n        workspace.activate_item(&item, true, true, window, cx);\n    }\n\n    pub fn set_gutter_hovered(&mut self, hovered: bool, cx: &mut Context<Self>) {\n        if hovered != self.gutter_hovered {\n            self.gutter_hovered = hovered;\n            cx.notify();\n        }\n    }\n\n    pub fn insert_blocks(\n        &mut self,\n        blocks: impl IntoIterator<Item = BlockProperties<Anchor>>,\n        autoscroll: Option<Autoscroll>,\n        cx: &mut Context<Self>,\n    ) -> Vec<CustomBlockId> {\n        let blocks = self\n            .display_map","sourceCodeStart":8726,"sourceCodeEnd":8762,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/editor/src/editor.rs#L8726-L8762","documentation":"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.","triggerScenarios":"Thrown at crates/editor/src/editor.rs:8648 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}