on master help sign in
Handle panic on move within empty picker (#1786)
1ac576fRohan Jain
helix-term/src/ui/picker.rs+5
@@ -415,6 +415,11 @@ impl<T> Picker<T> {
415 pub fn move_by(&mut self, amount: usize, direction: Direction) {
415 pub fn move_by(&mut self, amount: usize, direction: Direction) {
416 let len = self.matches.len();
416 let len = self.matches.len();
417
417
418+ if len == 0 {
419+ // No results, can't move.
420+ return;
421+ }
422+
418 match direction {
423 match direction {
419 Direction::Forward => {
424 Direction::Forward => {
420 self.cursor = self.cursor.saturating_add(amount) % len;
425 self.cursor = self.cursor.saturating_add(amount) % len;