summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpantosaur <44764250+pantosaur@users.noreply.github.com>2024-02-13 16:56:22 -0500
committerGitHub <noreply@github.com>2024-02-13 16:56:22 -0500
commit203bd8977b56218d3972de007d403a3fdf9d95f7 (patch)
tree35c587024ed9ebeb2927396714d266ca5618e328
parent33a5dba41cfc76d6f900c4f4522ad9ced9aa26ab (diff)
fix overflow bug on bookmark widget when area is too small (#483)
-rw-r--r--src/commands/bookmark.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/commands/bookmark.rs b/src/commands/bookmark.rs
index 4372a58..2371c44 100644
--- a/src/commands/bookmark.rs
+++ b/src/commands/bookmark.rs
@@ -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);