diff --git a/tui-react/src/list.rs b/tui-react/src/list.rs index 010a5e1..2f3531f 100644 --- a/tui-react/src/list.rs +++ b/tui-react/src/list.rs @@ -15,7 +15,7 @@ impl List { fn list_offset_for(&self, entry_in_view: Option, height: usize) -> usize { match entry_in_view { Some(pos) => match height as usize { - h if self.offset + h - 1 < pos => pos - h + 1, + h if self.offset + h.saturating_sub(1) < pos => pos.saturating_sub(h + 1), _ if self.offset > pos => pos, _ => self.offset, },