From 852e36327112d804db62fdc5d2a34fd5eb21f88e Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Fri, 7 Feb 2020 20:10:49 +0100 Subject: Fix preselection The preselected item is not searched for if the range of days is changed (day_changed = 1). The patch is meant to future-proof the selected-item-algorithm and is backwards compatible. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/calcurse.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calcurse.c b/src/calcurse.c index 1f0696d..3d8905f 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -49,11 +49,12 @@ int count, reg; */ static void do_storage(int day_changed) { + int pre_sel; /* * Save the selected item before rebuilding the day vector - - * unless already set. + * unless a preselection is already set. */ - if (!day_check_sel_data()) + if (!(pre_sel = day_check_sel_data())) day_set_sel_data(ui_day_get_sel()); if (!day_changed) @@ -64,7 +65,7 @@ static void do_storage(int day_changed) /* The APP listbox. */ ui_day_load_items(); - if (day_changed) + if (day_changed && !pre_sel) ui_day_sel_reset(); else ui_day_find_sel(); -- cgit v1.2.3-70-g09d2