fix crash with empty tables

This commit is contained in:
Robin Appelman 2025-11-05 18:23:52 +01:00
commit 8f0e443275

View file

@ -78,6 +78,9 @@ impl ScrollbarTableState {
}
pub fn up(&mut self, step: usize, rollover: bool) -> usize {
if self.count == 0 {
return 0;
}
let current = self.table.selected().unwrap_or(0);
let after = if step > current {
if rollover {
@ -94,6 +97,9 @@ impl ScrollbarTableState {
}
pub fn down(&mut self, step: usize, rollover: bool) -> usize {
if self.count == 0 {
return 0;
}
let current = self.table.selected().unwrap_or(0);
let after = if step >= self.count - current {
if rollover {