editor: Fix an error when cut with vim visual line select (#17591)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run

Becuause in vim visual mode, we will always select next char, hit
[here](66ef318823/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 <conrad.irwin@gmail.com>
This commit is contained in:
CharlesChen0823 2024-09-13 04:55:59 +08:00 committed by GitHub
parent 461812d7b6
commit 3613ebd93c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {