Skip to content

Commit

Permalink
fix overflow bug on bookmark widget when area is too small (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
pantosaur authored Feb 13, 2024
1 parent 33a5dba commit 203bd89
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/commands/bookmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ fn poll_for_bookmark_key(context: &mut AppContext, backend: &mut AppBackend) ->
frame.render_widget(view, area);
}

let menu_widget = TuiMenu::new(bookmarks_str.as_slice());
let menu_len = menu_widget.len();
let menu_y = if menu_len + 1 > area.height as usize {
0
let (menu_widget, menu_y) = if bookmarks_str.len() > area.height as usize - 1 {
(TuiMenu::new(&bookmarks_str[0..area.height as usize - 1]), 0)
} else {
(area.height as usize - menu_len - 1) as u16
(
TuiMenu::new(bookmarks_str.as_slice()),
(area.height as usize - bookmarks_str.len() - 1) as u16,
)
};

let menu_rect = Rect {
x: 0,
y: menu_y - 1,
y: menu_y,
width: area.width,
height: menu_len as u16 + 1,
height: menu_widget.len() as u16 + 1,
};
frame.render_widget(Clear, menu_rect);
frame.render_widget(menu_widget, menu_rect);
Expand Down

0 comments on commit 203bd89

Please sign in to comment.