From 6bc0b87040ac3a466743bcf6268919fa25483fdd Mon Sep 17 00:00:00 2001 From: Yung Siang Liau Date: Sun, 22 Oct 2023 01:51:35 +0800 Subject: [PATCH] Fix potential overflow panic --- src/view.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view.rs b/src/view.rs index a0ac30b..8e0ae58 100644 --- a/src/view.rs +++ b/src/view.rs @@ -435,7 +435,7 @@ impl RowsView { match control { Control::ScrollDown => { if let Some(i) = self.selection.row.index() { - if i >= self.num_rows_rendered - 1 { + if i >= self.num_rows_rendered.saturating_sub(1) { self.increase_rows_from(1)?; } else { self.selection.row.select_next();