Skip to content

Commit

Permalink
editor: Fix an error when cut with vim visual line select (zed-indust…
Browse files Browse the repository at this point in the history
…ries#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 zed-industries#17585 

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <[email protected]>
  • Loading branch information
CharlesChen0823 and ConradIrwin authored Sep 12, 2024
1 parent 461812d commit 3613ebd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3613ebd

Please sign in to comment.