Commit 35ae06c1 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Fix tag-prefix to not abort on $timeout.

If $timeout is set very low, then it can cancel the tag-prefix before
the user has time to press the desired command.

Change the code to set the tag flag, and then recontinue with normal
event processing instead.  Cancel on an abort, but continue with a timeout.

Thanks to Lauri Tirkkonen for reporting the issue.
parent 054164bf
......@@ -580,7 +580,11 @@ int mutt_index_menu (void)
FOREVER
{
tag = 0; /* clear the tag-prefix */
/* Clear the tag prefix unless we just started it. Don't clear
* the prefix on a timeout (op==-2), but do clear on an abort (op==-1)
*/
if (tag && op != OP_TAG_PREFIX && op != OP_TAG_PREFIX_COND && op != -2)
tag = 0;
/* check if we need to resort the index because just about
* any 'op' below could do mutt_enter_command(), either here or
......@@ -671,6 +675,13 @@ int mutt_index_menu (void)
{
index_menu_redraw (menu);
/* give visual indication that the next command is a tag- command */
if (tag)
{
mutt_window_mvaddstr (MuttMessageWindow, 0, 0, "tag-");
mutt_window_clrtoeol (MuttMessageWindow);
}
if (menu->current < menu->max)
menu->oldcurrent = menu->current;
else
......@@ -705,44 +716,27 @@ int mutt_index_menu (void)
dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
/* either user abort or timeout */
if (op < 0)
continue; /* either user abort or timeout */
{
if (tag)
mutt_window_clearline (MuttMessageWindow, 0);
continue;
}
mutt_curs_set (1);
/* special handling for the tag-prefix function */
if (op == OP_TAG_PREFIX)
if (op == OP_TAG_PREFIX || op == OP_TAG_PREFIX_COND)
{
if (!Context)
{
mutt_error _("No mailbox is open.");
continue;
}
if (!Context->tagged)
{
mutt_error _("No tagged messages.");
continue;
}
tag = 1;
/* give visual indication that the next command is a tag- command */
mutt_window_mvaddstr (MuttMessageWindow, 0, 0, "tag-");
mutt_window_clrtoeol (MuttMessageWindow);
/* get the real command */
if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
{
/* abort tag sequence */
/* A second tag-prefix command aborts */
if (tag)
{
tag = 0;
mutt_window_clearline (MuttMessageWindow, 0);
continue;
}
}
else if (option (OPTAUTOTAG) && Context && Context->tagged)
tag = 1;
continue;
}
if (op == OP_TAG_PREFIX_COND)
{
if (!Context)
{
mutt_error _("No mailbox is open.");
......@@ -751,24 +745,22 @@ int mutt_index_menu (void)
if (!Context->tagged)
{
mutt_flush_macro_to_endcond ();
mutt_message _("Nothing to do.");
if (op == OP_TAG_PREFIX)
mutt_error _("No tagged messages.");
else if (op == OP_TAG_PREFIX_COND)
{
mutt_flush_macro_to_endcond ();
mutt_message _("Nothing to do.");
}
continue;
}
tag = 1;
/* give visual indication that the next command is a tag- command */
mutt_window_mvaddstr (MuttMessageWindow, 0, 0, "tag-");
mutt_window_clrtoeol (MuttMessageWindow);
/* get the real command */
if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
{
/* abort tag sequence */
mutt_window_clearline (MuttMessageWindow, 0);
continue;
}
/* get the real command */
tag = 1;
continue;
}
else if (option (OPTAUTOTAG) && Context && Context->tagged)
tag = 1;
mutt_clear_error ();
}
......
......@@ -979,19 +979,30 @@ int mutt_menuLoop (MUTTMENU *menu)
unset_option (OPTMENUCALLER);
return OP_NULL;
}
/* Clear the tag prefix unless we just started it. Don't clear
* the prefix on a timeout (i==-2), but do clear on an abort (i==-1)
*/
if (menu->tagprefix &&
i != OP_TAG_PREFIX && i != OP_TAG_PREFIX_COND && i != -2)
menu->tagprefix = 0;
mutt_curs_set (0);
if (menu_redraw (menu) == OP_REDRAW)
return OP_REDRAW;
/* give visual indication that the next command is a tag- command */
if (menu->tagprefix)
{
mutt_window_mvaddstr (menu->messagewin, 0, 0, "tag-");
mutt_window_clrtoeol (menu->messagewin);
}
menu->oldcurrent = menu->current;
/* move the cursor out of the way */
if (option (OPTARROWCURSOR))
mutt_window_move (menu->indexwin, menu->current - menu->top + menu->offset, 2);
else if (option (OPTBRAILLEFRIENDLY))
......@@ -1001,21 +1012,25 @@ int mutt_menuLoop (MUTTMENU *menu)
menu->indexwin->cols - 1);
mutt_refresh ();
/* try to catch dialog keys before ops */
if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
return i;
i = km_dokey (menu->menu);
if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND)
{
if (menu->tagprefix)
{
menu->tagprefix = 0;
mutt_window_clearline (menu->messagewin, 0);
continue;
}
if (menu->tagged)
{
mutt_window_mvaddstr (menu->messagewin, 0, 0, "Tag-");
mutt_window_clrtoeol (menu->messagewin);
i = km_dokey (menu->menu);
menu->tagprefix = 1;
mutt_window_clearline (menu->messagewin, 0);
continue;
}
else if (i == OP_TAG_PREFIX)
{
......@@ -1031,8 +1046,6 @@ int mutt_menuLoop (MUTTMENU *menu)
}
else if (menu->tagged && option (OPTAUTOTAG))
menu->tagprefix = 1;
else
menu->tagprefix = 0;
mutt_curs_set (1);
......@@ -1046,7 +1059,11 @@ int mutt_menuLoop (MUTTMENU *menu)
#endif
if (i < 0)
{
if (menu->tagprefix)
mutt_window_clearline (menu->messagewin, 0);
continue;
}
if (!menu->dialog)
mutt_clear_error ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment