diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e0c5081..d5a0f8d 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -112,6 +112,7 @@ pub struct AppState { pub toast: Option, pub icon_mode: IconMode, pub github_token: Option, + pub terminal_height: u16, pub download_path: Option, pub full_tree: Option>, pub folder_sizes: HashMap, @@ -155,6 +156,7 @@ impl AppState { toast: None, icon_mode: IconMode::Emoji, github_token: None, + terminal_height: 24, download_path: None, full_tree: None, folder_sizes: HashMap::new(), @@ -207,7 +209,16 @@ impl AppState { } fn adjust_scroll(&mut self) { - let visible_height = 10; + // Base chrome: breadcrumb (3) + file list borders (2) + header row (1) + help bar (2) + let mut chrome_height: u16 = 8; + if self.downloading { + chrome_height += 2; // download status bar + } + if self.is_searching { + chrome_height += 3; // search bar with borders + } + let visible_height = (self.terminal_height.saturating_sub(chrome_height)) as usize; + let visible_height = visible_height.max(1); if self.cursor < self.scroll_offset { self.scroll_offset = self.cursor; } else if self.cursor >= self.scroll_offset + visible_height { @@ -488,6 +499,7 @@ async fn event_loop( terminal.draw(|f| { let size = f.size(); + state_lock.terminal_height = size.height; f.render_widget( ratatui::widgets::Block::default() .style(ratatui::style::Style::default().bg(theme::BG_COLOR)),