mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user