Skip to content

Commit

Permalink
Move pager_read_delay check to after the blocking km_dokey()
Browse files Browse the repository at this point in the history
The blocking part of the event loop of the pager is waiting for inputs
by the user.  When we check for an expired timer, we should do this
after this waiting.

Since handling the key event might alter the internal state such as the
currently selected message, we must handle the expired timer events
before the key events otherwise we might ending up operating on the
wrong message.
  • Loading branch information
rayfordshire authored and flatcap committed Jan 29, 2023
1 parent af370e0 commit 5fcc6c9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pager/dlg_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,6 @@ int mutt_pager(struct PagerView *pview)
priv->loop = PAGER_LOOP_CONTINUE;
do
{
if (check_read_delay(&priv->delay_read_timestamp))
{
mutt_set_flag(shared->mailbox, shared->email, MUTT_READ, true);
}

pager_queue_redraw(priv, PAGER_REDRAW_PAGER);
notify_send(priv->notify, NT_PAGER, NT_PAGER_VIEW, priv);
window_redraw(NULL);
Expand Down Expand Up @@ -522,6 +517,16 @@ int mutt_pager(struct PagerView *pview)
// Some OP codes are not handled by pager, they cause pager to quit returning
// OP code to index. Index handles the operation and then restarts pager
op = km_dokey(MENU_PAGER);

// km_dokey() can block, so recheck the timer.
// Note: This check must occur before handling the operations of the index
// as those can change the currently selected message/entry yielding to
// marking the wrong message as read.
if (check_read_delay(&priv->delay_read_timestamp))
{
mutt_set_flag(shared->mailbox, shared->email, MUTT_READ, true);
}

if (SigWinch)
priv->pager_redraw = true;

Expand Down

0 comments on commit 5fcc6c9

Please sign in to comment.