diff --git a/src/tui/tests/widgets/content/tabs.rs b/src/tui/tests/widgets/content/tabs.rs index 483ac36..e30f33a 100644 --- a/src/tui/tests/widgets/content/tabs.rs +++ b/src/tui/tests/widgets/content/tabs.rs @@ -44,6 +44,12 @@ fn discovery_version_rows_only_show_the_version_number() { assert_eq!(discovery_version_label(&version), "3.2.4-fabric-26.1"); } +#[test] +fn discovery_confirmation_popup_fits_its_summary() { + assert_eq!(version_popup_height(false), VERSION_POPUP_HEIGHT); + assert_eq!(version_popup_height(true), 6); +} + #[test] fn discovery_version_popup_renders_over_a_project_page() { use crate::instance::ContentKind; diff --git a/src/tui/tests/widgets/popups/import_modpack/render.rs b/src/tui/tests/widgets/popups/import_modpack/render.rs index 50812cf..ec9e301 100644 --- a/src/tui/tests/widgets/popups/import_modpack/render.rs +++ b/src/tui/tests/widgets/popups/import_modpack/render.rs @@ -155,6 +155,14 @@ fn import_modpack_renders_confirm_step() { insta::assert_snapshot!(terminal.backend()); } +#[test] +fn modpack_confirmation_area_fits_its_summary() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + reset_import_state(ImportStep::Confirm); + + assert_eq!(popup_rect(Rect::new(0, 0, 100, 30)).height, 8); +} + // Confirm step with loader_version=None: covers the branch where the // pack didn't declare a loader version (rare upstream, but happens for // older mmc packs). render_confirm_step has to handle the Option. diff --git a/src/tui/tests/widgets/popups/new_instance/render.rs b/src/tui/tests/widgets/popups/new_instance/render.rs index a766ab4..627399e 100644 --- a/src/tui/tests/widgets/popups/new_instance/render.rs +++ b/src/tui/tests/widgets/popups/new_instance/render.rs @@ -138,3 +138,11 @@ fn new_instance_renders_confirm_step() { .unwrap(); insta::assert_snapshot!(terminal.backend()); } + +#[test] +fn new_instance_confirmation_area_fits_its_summary() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + reset_wizard_state(WizardStep::Confirm); + + assert_eq!(popup_rect(Rect::new(0, 0, 100, 30)).height, 6); +} diff --git a/src/tui/widgets/content/tabs.rs b/src/tui/widgets/content/tabs.rs index 1f04049..ea889d5 100644 --- a/src/tui/widgets/content/tabs.rs +++ b/src/tui/widgets/content/tabs.rs @@ -618,7 +618,9 @@ fn render_version_popup(frame: &mut Frame, area: Rect, state: &DiscoveryState) { }; let popup_area = area.centered( Constraint::Percentage(50), - Constraint::Length(VERSION_POPUP_HEIGHT.min(area.height.saturating_sub(2))), + Constraint::Length( + version_popup_height(popup.confirming).min(area.height.saturating_sub(2)), + ), ); let theme = THEME.as_ref(); let title = popup.title(); @@ -727,6 +729,10 @@ fn render_version_popup(frame: &mut Frame, area: Rect, state: &DiscoveryState) { frame.render_widget(popup, popup_area); } +fn version_popup_height(confirming: bool) -> u16 { + if confirming { 6 } else { VERSION_POPUP_HEIGHT } +} + fn confirmation_values(values: &[String]) -> String { if values.is_empty() { "Unknown".to_owned() diff --git a/src/tui/widgets/popups/import_modpack/render.rs b/src/tui/widgets/popups/import_modpack/render.rs index 5edbfe9..9e55c49 100644 --- a/src/tui/widgets/popups/import_modpack/render.rs +++ b/src/tui/widgets/popups/import_modpack/render.rs @@ -110,7 +110,7 @@ pub fn popup_rect(frame_area: Rect) -> Rect { frame_area.centered(w, Constraint::Length(h)) } ImportStep::Confirm => { - let h = 10u16.min(frame_area.height.saturating_sub(4)); + let h = 8u16.min(frame_area.height.saturating_sub(4)); frame_area.centered(w, Constraint::Length(h)) } } diff --git a/src/tui/widgets/popups/new_instance/render.rs b/src/tui/widgets/popups/new_instance/render.rs index 382a2aa..50574c4 100644 --- a/src/tui/widgets/popups/new_instance/render.rs +++ b/src/tui/widgets/popups/new_instance/render.rs @@ -108,7 +108,7 @@ pub fn popup_rect(frame_area: Rect) -> Rect { frame_area.centered(w, Constraint::Length(h)) } WizardStep::Confirm => { - let h = 8u16.min(frame_area.height.saturating_sub(4)); + let h = 6u16.min(frame_area.height.saturating_sub(4)); frame_area.centered(w, Constraint::Length(h)) } }