Fix kill-selection crash when selection start is out-of-bounds

This part of the code could use some love; when we happen to clear the
selected text, we should end the selection.

But that's not how it works today. This is fine for Vi mode, because Vi
mode never deletes in visual mode.

Let's fix the crash for now.

Fixes #11367

(cherry picked from commit af3b49bf9c)
This commit is contained in:
Johannes Altmanninger
2025-04-11 09:48:28 +02:00
parent d95b662542
commit d622949d26
2 changed files with 19 additions and 1 deletions

View File

@@ -3705,8 +3705,11 @@ fn clear_pager(&mut self) {
fn get_selection(&self) -> Option<Range<usize>> {
let selection = self.selection?;
let start = selection.start;
let start = std::cmp::min(selection.start, self.command_line.len());
let end = std::cmp::min(selection.stop, self.command_line.len());
if start == end {
return None;
}
Some(start..end)
}