]> granicus.if.org Git - neomutt/commitdiff
jump to a collapsed email
authorFloyd Anderson <f.a@31c0.net>
Tue, 13 Mar 2018 16:09:53 +0000 (16:09 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 2 May 2018 12:42:23 +0000 (13:42 +0100)
When jumping to an email, e.g. "34<enter>", NeoMutt will now ensure that
the target is visible: on-screen and thread opened.

curs_main.c

index 33a8964745b190118492c317762749e7c0f42a62..c483f0a3b50ab89ea85a095919a36953e69045ac 100644 (file)
@@ -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;