From a672ef341940a9ed80e0c2382378d06356855920 Mon Sep 17 00:00:00 2001 From: PiotrekPKP Date: Sat, 21 May 2022 14:08:06 +0200 Subject: [PATCH] fix: Fixed scrolling with no elements in the list --- src/window/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window/mod.rs b/src/window/mod.rs index 06cdbd1..cbfe759 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -83,7 +83,7 @@ impl Window { Inhibit(false) } KEY_DOWN_ARROW => { - let new_selection = std::cmp::min(selection_model.n_items() - 1, selection_model.selected() + 1); + let new_selection = if selection_model.n_items() > 0 { std::cmp::min(selection_model.n_items() - 1, selection_model.selected() + 1) } else { 0 }; selection_model.select_item(new_selection, true); window.imp().crab_items_list.activate_action("list.scroll-to-item", Some(&new_selection.to_variant())).unwrap();