From 42357b974961e41737ff52a5e42551ebd769ddb3 Mon Sep 17 00:00:00 2001 From: Trevor Campbell Date: Sun, 21 Jul 2024 14:51:58 +1000 Subject: [PATCH] Fix out of range error when traversing menus --- src/widgets/menu/menu_tree.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/menu/menu_tree.rs b/src/widgets/menu/menu_tree.rs index a747308e..e1a5448d 100644 --- a/src/widgets/menu/menu_tree.rs +++ b/src/widgets/menu/menu_tree.rs @@ -390,8 +390,8 @@ where let menu_state = tree.state.downcast_ref::(); let slice = &menu_state.slice; - let max_item_slice = self.items.len().min(slice.end_index); - let max_tree_slice = tree.children.len().min(slice.end_index); + let max_item_slice = self.items.len()-1.min(slice.end_index); + let max_tree_slice = tree.children.len()-1.min(slice.end_index); self.items[slice.start_index..=max_item_slice] .iter()