From a5b898c718499da57d8e41fb77e445ff4d3015b6 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Tue, 22 Aug 2023 13:19:17 +0200 Subject: [PATCH] fix potential panic --- src/ui/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 3bff9e46..f0ee1539 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -22,7 +22,7 @@ pub const fn calc_scroll_top( height_in_lines: usize, selection: usize, ) -> usize { - if current_top + height_in_lines <= selection { + if current_top.saturating_add(height_in_lines) <= selection { selection.saturating_sub(height_in_lines) + 1 } else if current_top > selection { selection