Skip to content

Commit

Permalink
fix: Wrap around the top of the picker menu when scrolling
Browse files Browse the repository at this point in the history
Forgot to port the improvements in menu.rs

Fixes #734
  • Loading branch information
archseer committed Sep 17, 2021
1 parent b02d872 commit c7d6e44
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,15 @@ impl<T> Picker<T> {
}

pub fn move_up(&mut self) {
self.cursor = self.cursor.saturating_sub(1);
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;
}

if self.cursor < self.matches.len() - 1 {
self.cursor += 1;
}
let len = self.matches.len();
let pos = (self.cursor + 1) % len;
self.cursor = pos;
}

pub fn selection(&self) -> Option<&T> {
Expand Down

0 comments on commit c7d6e44

Please sign in to comment.