diff --git a/src/tui/tests/widgets/content/tabs.rs b/src/tui/tests/widgets/content/tabs.rs index 082886b..dc2ed33 100644 --- a/src/tui/tests/widgets/content/tabs.rs +++ b/src/tui/tests/widgets/content/tabs.rs @@ -106,3 +106,10 @@ fn confirmation_metadata_is_human_readable() { ); assert_eq!(confirmation_values(&[]), "Unknown"); } + +#[test] +fn empty_world_picker_only_offers_exit_actions() { + let keybinds = world_picker_keybinds(false); + assert!(!keybinds.iter().any(|(key, _)| *key == "Enter")); + assert!(!keybinds.iter().any(|(key, _)| *key == "j/k")); +} diff --git a/src/tui/widgets/content/tabs.rs b/src/tui/widgets/content/tabs.rs index 44e27b1..05869dd 100644 --- a/src/tui/widgets/content/tabs.rs +++ b/src/tui/widgets/content/tabs.rs @@ -924,16 +924,12 @@ fn render_world_picker( let theme = THEME.as_ref(); let title = popup.title(); let provider_label = popup.provider_label().to_owned(); + let keybinds = world_picker_keybinds(!popup.worlds.entries.is_empty()); let frame_widget = crate::tui::widgets::popups::base::PopupFrame { title: styled_title(&title, false), border_color: theme.accent(), bg: Some(theme.surface()), - keybinds: Some(crate::tui::widgets::popups::keybind_line(&[ - ("j/k", " navigate"), - ("Enter", " continue"), - ("h", " back"), - ("Esc", " close"), - ])), + keybinds: Some(crate::tui::widgets::popups::keybind_line(keybinds)), search_line: Some( Line::from(Span::styled( format!(" {provider_label} "), @@ -959,6 +955,19 @@ fn render_world_picker( ); } +fn world_picker_keybinds(has_worlds: bool) -> &'static [(&'static str, &'static str)] { + if has_worlds { + &[ + ("j/k", " navigate"), + ("Enter", " continue"), + ("h", " back"), + ("Esc", " close"), + ] + } else { + &[("h", " back"), ("Esc", " close")] + } +} + fn version_popup_height( confirming: bool, plan: Option<&crate::instance::content::dependencies::DependencyPlan>,