From ac30b3d10887006997345a0b979c8ee6e2af692f Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Thu, 19 May 2022 08:04:56 +0000 Subject: [PATCH] Fix menu panic for empty examples. (#5581) --- crates/nu-cli/src/menus/description_menu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/nu-cli/src/menus/description_menu.rs b/crates/nu-cli/src/menus/description_menu.rs index 909918a728..03ef4b71d7 100644 --- a/crates/nu-cli/src/menus/description_menu.rs +++ b/crates/nu-cli/src/menus/description_menu.rs @@ -586,7 +586,7 @@ impl Menu for DescriptionMenu { } else { self.example_index = Some(self.examples.len().saturating_sub(1)); } - } else { + } else if !self.examples.is_empty() { self.example_index = Some(0); } } @@ -598,7 +598,7 @@ impl Menu for DescriptionMenu { } else { self.example_index = Some(0); } - } else { + } else if !self.examples.is_empty() { self.example_index = Some(0); } }