Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent: Do not insert selection as context when selection is empty (#29031)

Bennet Bo Fenner3538acec7c2b
diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs
index 080ce42221c..e26e2816d2a 100644
--- a/crates/assistant_context_editor/src/context_editor.rs
+++ b/crates/assistant_context_editor/src/context_editor.rs
@@ -1813,7 +1813,10 @@ impl ContextEditor {
.selections
.all_adjusted(cx)
.into_iter()
- .map(|s| snapshot.anchor_after(s.start)..snapshot.anchor_before(s.end))
+ .filter_map(|s| {
+ (!s.is_empty())
+ .then(|| snapshot.anchor_after(s.start)..snapshot.anchor_before(s.end))
+ })
.collect::<Vec<_>>()
});
Some((selections, buffer))