From 69f853165a00ad7642c8d589871cb6e2774bf7f1 Mon Sep 17 00:00:00 2001 From: Floyd Anderson Date: Tue, 13 Mar 2018 16:09:53 +0000 Subject: [PATCH] jump to a collapsed email When jumping to an email, e.g. "34", NeoMutt will now ensure that the target is visible: on-screen and thread opened. --- curs_main.c | 60 +++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/curs_main.c b/curs_main.c index 33a896474..c483f0a3b 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1331,54 +1331,36 @@ int mutt_index_menu(void) if (isdigit(LastKey)) mutt_unget_event(LastKey, 0); buf[0] = 0; - if (mutt_get_field(_("Jump to message: "), buf, sizeof(buf), 0) != 0 || !buf[0]) + if ((mutt_get_field(_("Jump to message: "), buf, sizeof(buf), 0) != 0) || + (buf[0] == '\0')) { - if (menu->menu == MENU_PAGER) - { - op = OP_DISPLAY_MESSAGE; - continue; - } - break; + mutt_error(_("Nothing to do.")); } - - if (mutt_str_atoi(buf, &i) < 0) - { + else if (mutt_str_atoi(buf, &i) < 0) mutt_error(_("Argument must be a message number.")); - break; - } - - if (i > 0 && i <= Context->msgcount) + else if ((i < 1) || (i >= Context->msgcount)) + mutt_error(_("Invalid message number.")); + else if (!message_is_visible(Context, i - 1)) + mutt_error(_("That message is not visible.")); + else { - for (j = i - 1; j < Context->msgcount; j++) - { - if (Context->hdrs[j]->virtual != -1) - break; - } - if (j >= Context->msgcount) - { - for (j = i - 2; j >= 0; j--) - { - if (Context->hdrs[j]->virtual != -1) - break; - } - } + struct Header *hdr = Context->hdrs[i - 1]; - if (j >= 0) + if (mutt_messages_in_thread(Context, hdr, 1) != 1) { - menu->current = Context->hdrs[j]->virtual; - if (menu->menu == MENU_PAGER) - { - op = OP_DISPLAY_MESSAGE; - continue; - } - else - menu->redraw = REDRAW_MOTION; + mutt_uncollapse_thread(Context, hdr); + mutt_set_virtual(Context); } - else - mutt_error(_("That message is not visible.")); + menu->current = hdr->virtual; + } + + if (menu->menu == MENU_PAGER) + { + op = OP_DISPLAY_MESSAGE; + continue; } else - mutt_error(_("Invalid message number.")); + menu->redraw = REDRAW_FULL; break; -- 2.40.0