mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.0.0634: cannot easily get to the last quickfix list
Problem: Cannot easily get to the last quickfix list. Solution: Add "$" as a value for the "nr" argument of getqflist() and setqflist(). (Yegappan Lakshmanan)
This commit is contained in:
@@ -4670,7 +4670,14 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
||||
{
|
||||
qi = GET_LOC_LIST(wp);
|
||||
if (qi == NULL)
|
||||
{
|
||||
/* If querying for the size of the location list, return 0 */
|
||||
if (((di = dict_find(what, (char_u *)"nr", -1)) != NULL) &&
|
||||
(di->di_tv.v_type == VAR_STRING) &&
|
||||
(STRCMP(di->di_tv.vval.v_string, "$") == 0))
|
||||
return dict_add_nr_str(retdict, "nr", 0, NULL);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
qf_idx = qi->qf_curlist; /* default is the current list */
|
||||
@@ -4685,6 +4692,18 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
||||
qf_idx = di->di_tv.vval.v_number - 1;
|
||||
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
|
||||
return FAIL;
|
||||
} else if (qi->qf_listcount == 0) /* stack is empty */
|
||||
return FAIL;
|
||||
flags |= QF_GETLIST_NR;
|
||||
} else if ((di->di_tv.v_type == VAR_STRING) &&
|
||||
(STRCMP(di->di_tv.vval.v_string, "$") == 0))
|
||||
{
|
||||
{
|
||||
/* Get the last quickfix list number */
|
||||
if (qi->qf_listcount > 0)
|
||||
qf_idx = qi->qf_listcount - 1;
|
||||
else
|
||||
qf_idx = -1; /* Quickfix stack is empty */
|
||||
}
|
||||
flags |= QF_GETLIST_NR;
|
||||
}
|
||||
@@ -4692,17 +4711,20 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (dict_find(what, (char_u *)"all", -1) != NULL)
|
||||
flags |= QF_GETLIST_ALL;
|
||||
if (qf_idx != -1)
|
||||
{
|
||||
if (dict_find(what, (char_u *)"all", -1) != NULL)
|
||||
flags |= QF_GETLIST_ALL;
|
||||
|
||||
if (dict_find(what, (char_u *)"title", -1) != NULL)
|
||||
flags |= QF_GETLIST_TITLE;
|
||||
if (dict_find(what, (char_u *)"title", -1) != NULL)
|
||||
flags |= QF_GETLIST_TITLE;
|
||||
|
||||
if (dict_find(what, (char_u *)"winid", -1) != NULL)
|
||||
flags |= QF_GETLIST_WINID;
|
||||
if (dict_find(what, (char_u *)"winid", -1) != NULL)
|
||||
flags |= QF_GETLIST_WINID;
|
||||
|
||||
if (dict_find(what, (char_u *)"context", -1) != NULL)
|
||||
flags |= QF_GETLIST_CONTEXT;
|
||||
if (dict_find(what, (char_u *)"context", -1) != NULL)
|
||||
flags |= QF_GETLIST_CONTEXT;
|
||||
}
|
||||
|
||||
if (flags & QF_GETLIST_TITLE)
|
||||
{
|
||||
@@ -4895,7 +4917,10 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action)
|
||||
qf_idx = di->di_tv.vval.v_number - 1;
|
||||
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
|
||||
return FAIL;
|
||||
}
|
||||
} else if (di->di_tv.v_type == VAR_STRING &&
|
||||
STRCMP(di->di_tv.vval.v_string, "$") == 0 &&
|
||||
qi->qf_listcount > 0)
|
||||
qf_idx = qi->qf_listcount - 1;
|
||||
else
|
||||
return FAIL;
|
||||
newlist = FALSE; /* use the specified list */
|
||||
@@ -4923,6 +4948,7 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action)
|
||||
if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
|
||||
{
|
||||
typval_T *ctx;
|
||||
|
||||
free_tv(qi->qf_lists[qf_idx].qf_ctx);
|
||||
ctx = alloc_tv();
|
||||
if (ctx != NULL)
|
||||
|
Reference in New Issue
Block a user