* If the current list is not "save_qfid" and we can find the list with that ID
* then make it the current list.
* This is used when autocommands may have changed the current list.
+ * Returns OK if successfully restored the list. Returns FAIL if the list with
+ * the specified identifier (save_qfid) is not found in the stack.
*/
- static void
+ static int
qf_restore_list(qf_info_T *qi, int_u save_qfid)
{
int curlist;
if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
{
curlist = qf_id2nr(qi, save_qfid);
- if (curlist >= 0)
- qi->qf_curlist = curlist;
- // else: what if the list can't be found?
+ if (curlist < 0)
+ // list is not present
+ return FAIL;
+ qi->qf_curlist = curlist;
}
+ return OK;
}
/*
static void
qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
{
- qf_restore_list(qi, save_qfid);
+ if (qf_restore_list(qi, save_qfid) == FAIL)
+ return;
- // Autocommands might have cleared the list, check for it
+ // Autocommands might have cleared the list, check for that.
if (!qf_list_empty(qi, qi->qf_curlist))
qf_jump(qi, 0, 0, forceit);
}
}
}
- qf_restore_list(qi, qfid);
+ if (qf_restore_list(qi, qfid) == FAIL)
+ return FALSE;
return TRUE;
}
if (!qflist_valid(wp, save_qfid))
goto theend;
- qf_restore_list(qi, save_qfid);
+ if (qf_restore_list(qi, save_qfid) == FAIL)
+ goto theend;
/* Jump to first match. */
if (!qf_list_empty(qi, qi->qf_curlist))