[BUG] Panic when opening empty menubar subtree
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 270
- Avg merge
- 5d 19h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
When creating a menubar with an empty subtree, panics when you select it in the menu.
Dealing with this as I want to create a dynamic menubar to select a file, although maybe this isn't the best approach.
**To Reproduce**
```rs
let mut siv = cursive::default();
siv.menubar().add_subtree("foo", Tree::new());
siv.add_global_callback(Key::Esc, |s| s.select_menubar());
siv.run();
// Then press escape, go to foo and press enter.
```
**Expected behavior**
Expected to not panic
**Environment**
* OS: Linux (Nobara 39)
* Backend used: ncurses
* Current locale: en_US
* Cursive version: 0.20.0
* Nightly rust in debug build
**Additional context**
Assuming index OOB error "len is 0 but index is 0":
https://github.com/gyscos/cursive/blob/0a95c82c88c8a791d7fd983e7fb9f568b77551a8/cursive-core/src/views/menu_popup.rs#L331
As panic points to around there (line 335 specifically).
Contributor guide
Assessment
This issue has not been assessed yet.