Skip to content

Commit

Permalink
Early return from MenuPopup::scroll_{up,down} when the menu is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Aug 27, 2024
1 parent 0221d08 commit fe88657
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cursive-core/src/views/menu_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ impl MenuPopup {
//
// If `self.menu.children.is_empty()`.
fn scroll_up(&mut self, mut n: usize, mut cycle: bool) {
if self.menu.is_empty() {
return;
}

while n > 0 {
if self.focus > 0 {
self.focus -= 1;
Expand All @@ -154,6 +158,10 @@ impl MenuPopup {
//
// If `self.menu.children.is_empty()`.
fn scroll_down(&mut self, mut n: usize, mut cycle: bool) {
if self.menu.is_empty() {
return;
}

while n > 0 {
if self.focus + 1 < self.menu.children.len() {
self.focus += 1;
Expand Down

0 comments on commit fe88657

Please sign in to comment.