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

Bennet Bo Fenner created

Release Notes:

- N/A

Change summary

crates/assistant_context_editor/src/context_editor.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Detailed changes

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))