on master help sign in
fix: ui/menu: Don't allow scrolling past the end of completion

Fixes #472

commit1789dfabfe68c00dda3b861b828ea7a50860f6e7 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 23 Jul 2021, 18:12 (5 years ago) parente5d4387
1 file changed+2−2
helix-term/src/ui/menu.rs+2−2
helix-term/src/ui/menu.rs+2−2
@@ -90,13 +90,13 @@ impl<T: Item> Menu<T> {
9090
9191 pub fn move_up(&mut self) {
9292 // TODO: wrap around to end
93− let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.options.len();
93+ let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.matches.len();
9494 self.cursor = Some(pos);
9595 self.adjust_scroll();
9696 }
9797
9898 pub fn move_down(&mut self) {
99− let pos = self.cursor.map_or(0, |i| i + 1) % self.options.len();
99+ let pos = self.cursor.map_or(0, |i| i + 1) % self.matches.len();
100100 self.cursor = Some(pos);
101101 self.adjust_scroll();
102102 }