From 3538acec7c2b85f86e3a1c1e4b62c9293d50900e Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Fri, 18 Apr 2025 11:31:26 +0200 Subject: [PATCH] agent: Do not insert selection as context when selection is empty (#29031) Release Notes: - N/A --- crates/assistant_context_editor/src/context_editor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs index 080ce42221..e26e2816d2 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::>() }); Some((selections, buffer))