From 2e5bc8dbce7dd593442db0bf4d9d9f68cacbfce7 Mon Sep 17 00:00:00 2001 From: Ultraxime Date: Sun, 18 Aug 2024 21:03:46 +0200 Subject: [PATCH] Correcting menu (index error when less than 2 items) --- 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 3e30be8d..c21d06d4 100644 --- a/src/widgets/menu/menu_tree.rs +++ b/src/widgets/menu/menu_tree.rs @@ -448,8 +448,8 @@ where let menu_state = tree.state.downcast_ref::(); let slice = &menu_state.slice; - let max_item_slice = self.items.len() - 1.min(slice.end_index); - let max_tree_slice = tree.children.len() - 1.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()