Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_ui: Insert images at cursor position (#48779)
Kunall Banerjeea41bec82f9c1
diff --git a/crates/agent_ui/src/mention_set.rs b/crates/agent_ui/src/mention_set.rsindex 53c6c8f531a..707e7b45343 100644--- a/crates/agent_ui/src/mention_set.rs+++ b/crates/agent_ui/src/mention_set.rs@@ -661,17 +661,12 @@ pub(crate) async fn insert_images_as_context(let (excerpt_id, _, buffer_snapshot) =snapshot.buffer_snapshot().as_singleton().unwrap();- let text_anchor = buffer_snapshot.anchor_before(buffer_snapshot.len());+ let cursor_anchor = editor.selections.newest_anchor().start.text_anchor;+ let text_anchor = cursor_anchor.bias_left(&buffer_snapshot);let multibuffer_anchor = snapshot.buffer_snapshot().anchor_in_excerpt(*excerpt_id, text_anchor);- editor.edit(- [(- multi_buffer::Anchor::max()..multi_buffer::Anchor::max(),- format!("{replacement_text} "),- )],- cx,- );+ editor.insert(&format!("{replacement_text} "), window, cx);(*excerpt_id, text_anchor, multibuffer_anchor)}).ok()