Clear pager position upon returning to the index menu.
authorKevin McCarthy <kevin@8t8.us>
Mon, 8 Aug 2016 20:13:30 +0000 (13:13 -0700)
committerKevin McCarthy <kevin@8t8.us>
Mon, 8 Aug 2016 20:13:30 +0000 (13:13 -0700)
This fixes a bug where opening a message sometimes shows it scrolled
down.

The easiest way to trigger this is to open a long message in a mailbox
with no new messages, scroll down, hit <next-new-then-unread> and then
reopen the message.  The pager will "remember" the position and scroll
down.  If you simply exit the message and re-enter it, the position is
not saved.

More annoyingly, once in a very great while I will open a new message
and have the message scrolled down partway.  I believe this is due to
OldHdr happening to point to the same address as the Header of the new
message.

This is somewhat easily triggered on a mailbox with one message, which
you open, scroll down in, hit <next-new-then-unread> to exit, and then
delete/sync.  In another mutt instance, copy the same messsage back to
the mailbox, then open the message in the original mutt instance.  At
least some of the time, the OldHdr pointer matches the new message,
and so it opens scrolled down.

This patch solves the problem by clearing the pager position once all
redirections through the index menu are done.

curs_main.c
pager.c
protos.h

index ca79388866d9b343adedd658342f8b14b3de7b84..8e0f52ad837eadbee37601851c2626956f4e9e01 100644 (file)
@@ -2371,6 +2371,7 @@ int mutt_index_menu (void)
 
     if (menu->menu == MENU_PAGER)
     {
+      mutt_clear_pager_position ();
       menu->menu = MENU_MAIN;
       menu->redraw = REDRAW_FULL;
 #if 0
diff --git a/pager.c b/pager.c
index 9404b7e143572fe264952d44424d7683d691501e..d7674eb30cb92cc31cfcf59ca39096e1f7624378 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1563,6 +1563,11 @@ static const struct mapping_t PagerHelpExtra[] = {
   { NULL,      0 }
 };
 
+void mutt_clear_pager_position (void)
+{
+  TopLine = 0;
+  OldHdr = NULL;
+}
 
 
 /* This pager is actually not so simple as it once was.  It now operates in
index c219515274ea7aff02eb22abf1b9ea094bc81e00..19d640032ae1da433f17215d5b46439a66c7781d 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -175,6 +175,7 @@ void mutt_canonical_charset (char *, size_t, const char *);
 int mutt_count_body_parts (CONTEXT *, HEADER *);
 void mutt_check_rescore (CONTEXT *);
 void mutt_clear_error (void);
+void mutt_clear_pager_position (void);
 void mutt_create_alias (ENVELOPE *, ADDRESS *);
 void mutt_decode_attachment (BODY *, STATE *);
 void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd);