Fix menu panic for empty examples. (#5581)

This commit is contained in:
Ian Manske 2022-05-19 08:04:56 +00:00 committed by GitHub
parent 2b1e05aad0
commit ac30b3d108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -586,7 +586,7 @@ impl Menu for DescriptionMenu {
} else { } else {
self.example_index = Some(self.examples.len().saturating_sub(1)); self.example_index = Some(self.examples.len().saturating_sub(1));
} }
} else { } else if !self.examples.is_empty() {
self.example_index = Some(0); self.example_index = Some(0);
} }
} }
@ -598,7 +598,7 @@ impl Menu for DescriptionMenu {
} else { } else {
self.example_index = Some(0); self.example_index = Some(0);
} }
} else { } else if !self.examples.is_empty() {
self.example_index = Some(0); self.example_index = Some(0);
} }
} }