diff options
author | Leoi Hung Kin | 2021-10-09 11:34:10 +0000 |
---|---|---|
committer | GitHub | 2021-10-09 11:34:10 +0000 |
commit | a6852fb88f72ea6bb41b19e65b531c17662ba57d (patch) | |
tree | 8da6b9c72228d3395e85cce54ace4f8bdb7a6cef | |
parent | eedcea7e6bdae7d18610ae8d035e7f732099e619 (diff) |
Picker: Don't panick at move_up/move_down when matches is empty (#818)
-rw-r--r-- | helix-term/src/ui/picker.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index c5b90a9c..9be2a73e 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -270,12 +270,18 @@ impl<T> Picker<T> { } pub fn move_up(&mut self) { + if self.matches.is_empty() { + return; + } let len = self.matches.len(); let pos = ((self.cursor + len.saturating_sub(1)) % len) % len; self.cursor = pos; } pub fn move_down(&mut self) { + if self.matches.is_empty() { + return; + } let len = self.matches.len(); let pos = (self.cursor + 1) % len; self.cursor = pos; |