From 8d9e4c61021fdbcf9fdfeb559e52bf03c1978971 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 18 Jul 2014 09:14:09 +0200 Subject: Always fix selection in listbox_load_items() Since commit 80a7267 (Fix selection in listbox_load_items(), 2014-07-18), listbox_fix_sel() is called if the selection is out of range after loading the new set of items. However, we should *always* fix the selection to make sure the selection doesn't move to a caption row when reloading items. Signed-off-by: Lukas Fleischer --- src/listbox.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/listbox.c b/src/listbox.c index a109b7f..98c1ee6 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -108,13 +108,11 @@ void listbox_load_items(struct listbox *lb, int item_count) wins_scrollwin_set_linecount(&(lb->sw), ch); - if (item_count > 0 && lb->item_sel < 0) { + if (item_count > 0 && lb->item_sel < 0) lb->item_sel = 0; - listbox_fix_sel(lb, 1); - } else if (lb->item_sel >= item_count) { + else if (lb->item_sel >= item_count) lb->item_sel = item_count - 1; - listbox_fix_sel(lb, -1); - } + listbox_fix_sel(lb, 1); } void listbox_draw_deco(struct listbox *lb, int hilt) -- cgit v1.2.3-70-g09d2