From 3613ebd93c137578d947b482fe108e81313a8b47 Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Fri, 13 Sep 2024 04:55:59 +0800 Subject: [PATCH] editor: Fix an error when cut with vim visual line select (#17591) Becuause in vim visual mode, we will always select next char, hit [here](https://github.com/zed-industries/zed/blob/66ef31882341852229c74996867916fbd4a2fe2a/crates/vim/src/visual.rs#L174), when using editor method for `cut` this selection, will hit this error. Closes #17585 Release Notes: - N/A --------- Co-authored-by: Conrad Irwin --- crates/editor/src/editor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4792c6b2cb889de7efbd00477af23f6cbe1bf5b5..515cde1908abb55f47aab5fece2a9c0960140382 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6671,7 +6671,11 @@ impl Editor { let is_entire_line = selection.is_empty() || self.selections.line_mode; if is_entire_line { selection.start = Point::new(selection.start.row, 0); - selection.end = cmp::min(max_point, Point::new(selection.end.row + 1, 0)); + if !selection.is_empty() && selection.end.column == 0 { + selection.end = cmp::min(max_point, selection.end); + } else { + selection.end = cmp::min(max_point, Point::new(selection.end.row + 1, 0)); + } selection.goal = SelectionGoal::None; } if is_first {