From 79cfd0aafeae3970315d454be7d263275222be83 Mon Sep 17 00:00:00 2001 From: Remigiusz Micielski Date: Tue, 6 Aug 2024 07:18:14 +0200 Subject: [PATCH 1/2] fix bar being freezed after moving left or right --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a9b455c..2e13ae1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -146,7 +146,9 @@ impl MenuState { /// /// down highlights "sub item 2" pub fn down(&mut self) { - if self.active_depth() == 1 { + if self.active_depth() == 0 { + // do nothing + } else if self.active_depth() == 1 { self.push(); } else { self.next(); @@ -176,7 +178,9 @@ impl MenuState { /// /// left pop "sub sub group" pub fn left(&mut self) { - if self.active_depth() == 1 { + if self.active_depth() == 0 { + // do nothing + } else if self.active_depth() == 1 { self.prev(); } else if self.active_depth() == 2 { self.pop(); From dca4b8c528ab36bd0648334ad9d595e96ae081cf Mon Sep 17 00:00:00 2001 From: Remigiusz Micielski Date: Tue, 6 Aug 2024 11:14:44 +0200 Subject: [PATCH 2/2] don't do anything in right() if depth is 0, not down --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2e13ae1..8338feb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -146,9 +146,7 @@ impl MenuState { /// /// down highlights "sub item 2" pub fn down(&mut self) { - if self.active_depth() == 0 { - // do nothing - } else if self.active_depth() == 1 { + if self.active_depth() == 1 { self.push(); } else { self.next(); @@ -213,7 +211,9 @@ impl MenuState { /// right pushes "sub sub item 2". this differs from case 2 that /// current highlighted item can be expanded pub fn right(&mut self) { - if self.active_depth() == 1 { + if self.active_depth() == 0 { + // do nothing + } else if self.active_depth() == 1 { self.next(); } else if self.active_depth() == 2 { if self.push().is_none() {