From 420fa60da9d7af5862c968f8b6f96b979f6db026 Mon Sep 17 00:00:00 2001 From: Kaian Date: Sun, 21 Feb 2016 20:46:14 +0100 Subject: [PATCH] sort: remember the selected list line This can result in some unexpected behaviours if the list has been loaded without user interaction. The first selected dialog could not be the first of the list after loading a file if sort order is descending. --- src/curses/ui_call_list.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/curses/ui_call_list.c b/src/curses/ui_call_list.c index da83962..84cfbea 100644 --- a/src/curses/ui_call_list.c +++ b/src/curses/ui_call_list.c @@ -289,14 +289,18 @@ call_list_draw_list(ui_t *ui) // Get panel info call_list_info_t *info = call_list_info(ui); - // Get the list of calls that are goint to be displayed - vector_destroy(info->dcalls); - info->dcalls = vector_copy_if(sip_calls_vector(), filter_check_call); - // Get window of call list panel list_win = info->list_win; getmaxyx(list_win, listh, listw); + // Store selected call + if (info->cur_call >= 0) + call = vector_item(info->dcalls, info->cur_call); + + // Get the list of calls that are goint to be displayed + vector_destroy(info->dcalls); + info->dcalls = vector_copy_if(sip_calls_vector(), filter_check_call); + // If no active call, use the fist one (if exists) if (info->cur_call == -1 && vector_count(info->dcalls)) { info->cur_call = info->scroll.pos = 0; @@ -305,6 +309,8 @@ call_list_draw_list(ui_t *ui) // If autoscroll is enabled, select the last dialog if (info->autoscroll) { call_list_move(ui, vector_count(info->dcalls) - 1); + } else if (call) { + call_list_move(ui, vector_index(info->dcalls, call)); } // Clear call list before redrawing