Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix missing selection range in Vim visual line mode in the assistant panel (#25133)
RieN 7z980e1b533ff0
diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rsindex 578d4636c98..12a522f56a3 100644--- a/crates/assistant_context_editor/src/context_editor.rs+++ b/crates/assistant_context_editor/src/context_editor.rs@@ -1514,15 +1514,11 @@ impl ContextEditor {(!text.is_empty()).then_some((text, true))} else {- let anchor = context_editor.selections.newest_anchor();- let text = context_editor- .buffer()- .read(cx)- .read(cx)- .text_for_range(anchor.range())- .collect::<String>();+ let selection = context_editor.selections.newest_adjusted(cx);+ let buffer = context_editor.buffer().read(cx).snapshot(cx);+ let selected_text = buffer.text_for_range(selection.range()).collect::<String>();- (!text.is_empty()).then_some((text, false))+ (!selected_text.is_empty()).then_some((selected_text, false))}})}@@ -1777,23 +1773,16 @@ impl ContextEditor {&mut self,cx: &mut Context<Self>,) -> (String, CopyMetadata, Vec<text::Selection<usize>>) {- let (snapshot, selection, creases) = self.editor.update(cx, |editor, cx| {- let mut selection = editor.selections.newest::<Point>(cx);+ let (selection, creases) = self.editor.update(cx, |editor, cx| {+ let mut selection = editor.selections.newest_adjusted(cx);let snapshot = editor.buffer().read(cx).snapshot(cx);- let is_entire_line = selection.is_empty() || editor.selections.line_mode;- if is_entire_line {- selection.start = Point::new(selection.start.row, 0);- selection.end =- cmp::min(snapshot.max_point(), Point::new(selection.start.row + 1, 0));- selection.goal = SelectionGoal::None;- }+ selection.goal = SelectionGoal::None;let selection_start = snapshot.point_to_offset(selection.start);(- snapshot.clone(),- selection.clone(),+ selection.map(|point| snapshot.point_to_offset(point)),editor.display_map.update(cx, |display_map, cx| {display_map.snapshot(cx)@@ -1833,7 +1822,6 @@ impl ContextEditor {)});- let selection = selection.map(|point| snapshot.point_to_offset(point));let context = self.context.read(cx);let mut text = String::new();