From 5dedc626ea3bf332dcbc001067ef3dac13c42a09 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 21 May 2019 16:13:10 -0700 Subject: [PATCH] entire-thread: determine current position before resorting. Previously oldcur was determined after nm_read_entire_thread(), leading to entire-thread unintentionally jumping to the first message in the thread. Before 918885f32db41 that used to work, because mutt_sort_headers() wasn't called from within nm_read_entire_thread(). Fix by moving determination of pre nm_read_entire_thread() count a few lines up. Also reuse existing oldcount variable, rather than 'oc' (which could also be oldcur). Fixes: #1714 --- index.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.c b/index.c index d5b32dd61..edb51e1a3 100644 --- a/index.c +++ b/index.c @@ -1983,16 +1983,15 @@ int mutt_index_menu(void) } if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE)) break; - int oc = Context->mailbox->msg_count; + oldcount = Context->mailbox->msg_count; + struct Email *oldcur = CUR_EMAIL; if (nm_read_entire_thread(Context->mailbox, CUR_EMAIL) < 0) { mutt_message(_("Failed to read thread, aborting")); break; } - if (oc < Context->mailbox->msg_count) + if (oldcount < Context->mailbox->msg_count) { - struct Email *oldcur = CUR_EMAIL; - if ((C_Sort & SORT_MASK) == SORT_THREADS) mutt_sort_headers(Context, false); menu->current = oldcur->virtual; -- 2.40.0