Mercurial > vim
diff src/quickfix.c @ 11502:46bbef0ee9a6 v8.0.0634
patch 8.0.0634: cannot easily get to the last quickfix list
commit https://github.com/vim/vim/commit/875feea6ce223462d55543735143d747dcaf4287
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 11 16:07:51 2017 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 11 Jun 2017 16:15:04 +0200 |
parents | d2f00eb352b9 |
children | 80491a71c716 |
line wrap: on
line diff
--- a/src/quickfix.c +++ b/src/quickfix.c @@ -4670,7 +4670,14 @@ get_errorlist_properties(win_T *wp, dict { 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 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 return FAIL; } - 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 *)"winid", -1) != NULL) - flags |= QF_GETLIST_WINID; - - if (dict_find(what, (char_u *)"context", -1) != NULL) - flags |= QF_GETLIST_CONTEXT; + 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 *)"winid", -1) != NULL) + flags |= QF_GETLIST_WINID; + + 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 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 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)