Skip to content

Commit

Permalink
Fixed sub-menu path in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindbergem committed Aug 30, 2024
1 parent 01e6f16 commit a7c5623
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,15 @@ impl<'a, I, T> PromptIter<'a, I, T> {
let state = if newline {
PromptIterState::Newline
} else {
PromptIterState::Menu(0)
Self::first_menu()
};
Self { menu_mgr, state }
}

const fn first_menu() -> PromptIterState {
// Skip the first menu level which is root
PromptIterState::Menu(1)
}
}

impl<'a, I, T> Iterator for PromptIter<'a, I, T> {
Expand All @@ -294,11 +299,11 @@ impl<'a, I, T> Iterator for PromptIter<'a, I, T> {
loop {
match self.state {
PromptIterState::Newline => {
self.state = PromptIterState::Menu(0);
self.state = Self::first_menu();
break Some("\n");
}
PromptIterState::Menu(i) => {
if i >= self.menu_mgr.depth() {
if i > self.menu_mgr.depth() {
self.state = PromptIterState::Arrow;
} else {
let menu = self.menu_mgr.get_menu(Some(i));
Expand Down

0 comments on commit a7c5623

Please sign in to comment.