Patch 8.0.1093
Problem: Various small quickfix issues.
Solution: Remove ":" prefix from title set by a user. Add the qf_id2nr().
function. Add a couple more tests. Update documentation.
(Yegappan Lakshmanan)
Files: runtime/doc/eval.txt, runtime/doc/quickfix.txt, src/evalfunc.c,
src/proto/quickfix.pro, src/quickfix.c,
src/testdir/test_quickfix.vim
*** ../vim-8.0.1092/runtime/doc/eval.txt 2017-09-08 14:39:25.638102889
+0200
--- runtime/doc/eval.txt 2017-09-11 19:23:18.935977799 +0200
***************
*** 4657,4668 ****
If "nr" is not present then the current quickfix list is used.
If both "nr" and a non-zero "id" are specified, then the list
specified by "id" is used.
! To get the number of lists in the quickfix stack, set 'nr' to
! '$' in {what}. The 'nr' value in the returned dictionary
contains the quickfix stack size.
! When 'text' is specified, all the other items are ignored. The
! returned dictionary contains the entry 'items' with the list
! of entries.
In case of error processing {what}, an empty dictionary is
returned.
--- 4657,4668 ----
If "nr" is not present then the current quickfix list is used.
If both "nr" and a non-zero "id" are specified, then the list
specified by "id" is used.
! To get the number of lists in the quickfix stack, set "nr" to
! "$" in {what}. The "nr" value in the returned dictionary
contains the quickfix stack size.
! When "lines" is specified, all the other items except "efm"
! are ignored. The returned dictionary contains the entry
! "items" with the list of entries.
In case of error processing {what}, an empty dictionary is
returned.
*** ../vim-8.0.1092/runtime/doc/quickfix.txt 2017-08-30 20:33:51.758040889
+0200
--- runtime/doc/quickfix.txt 2017-09-11 19:21:15.976697120 +0200
***************
*** 49,54 ****
--- 49,61 ----
number will not change within a Vim session. The getqflist() function can be
used to get the identifier assigned to a list.
+ *quickfix-ID*
+ Each quickfix list has a unique identifier called the quickfix ID and this
+ number will not change within a Vim session. The getqflist() function can be
+ used to get the identifier assigned to a list. There is also a quickfix list
+ number which may change whenever more than ten lists are added to a quickfix
+ stack.
+
*location-list* *E776*
A location list is a window-local quickfix list. You get one after commands
like `:lvimgrep`, `:lgrep`, `:lhelpgrep`, `:lmake`, etc., which create a
*** ../vim-8.0.1092/src/evalfunc.c 2017-09-09 16:25:49.154576764 +0200
--- src/evalfunc.c 2017-09-11 19:21:15.976697120 +0200
***************
*** 4826,4832 ****
dict_T *d = what_arg->vval.v_dict;
if (d != NULL)
! get_errorlist_properties(wp, d, rettv->vval.v_dict);
}
else
EMSG(_(e_dictreq));
--- 4826,4832 ----
dict_T *d = what_arg->vval.v_dict;
if (d != NULL)
! qf_get_properties(wp, d, rettv->vval.v_dict);
}
else
EMSG(_(e_dictreq));
*** ../vim-8.0.1092/src/proto/quickfix.pro 2017-08-27 15:23:37.512977267
+0200
--- src/proto/quickfix.pro 2017-09-11 19:21:15.980697097 +0200
***************
*** 22,28 ****
void ex_cfile(exarg_T *eap);
void ex_vimgrep(exarg_T *eap);
int get_errorlist(qf_info_T *qi, win_T *wp, int qf_idx, list_T *list);
! int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict);
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, dict_T
*what);
int set_ref_in_quickfix(int copyID);
void ex_cbuffer(exarg_T *eap);
--- 22,28 ----
void ex_cfile(exarg_T *eap);
void ex_vimgrep(exarg_T *eap);
int get_errorlist(qf_info_T *qi, win_T *wp, int qf_idx, list_T *list);
! int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict);
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, dict_T
*what);
int set_ref_in_quickfix(int copyID);
void ex_cbuffer(exarg_T *eap);
*** ../vim-8.0.1092/src/quickfix.c 2017-09-02 19:51:40.734765887 +0200
--- src/quickfix.c 2017-09-11 19:21:15.980697097 +0200
***************
*** 4691,4702 ****
}
/*
* Return quickfix/location list details (title) as a
* dictionary. 'what' contains the details to return. If 'list_idx' is -1,
* then current list is used. Otherwise the specified list is used.
*/
int
! get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
{
qf_info_T *qi = &ql_info;
int status = OK;
--- 4691,4717 ----
}
/*
+ * Return the quickfix/location list number with the given identifier.
+ * Returns -1 if list is not found.
+ */
+ static int
+ qf_id2nr(qf_info_T *qi, int_u qfid)
+ {
+ int qf_idx;
+
+ for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
+ if (qi->qf_lists[qf_idx].qf_id == qfid)
+ return qf_idx;
+ return -1;
+ }
+
+ /*
* Return quickfix/location list details (title) as a
* dictionary. 'what' contains the details to return. If 'list_idx' is -1,
* then current list is used. Otherwise the specified list is used.
*/
int
! qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
{
qf_info_T *qi = &ql_info;
int status = OK;
***************
*** 4752,4763 ****
/* For zero, use the current list or the list specifed by 'nr' */
if (di->di_tv.vval.v_number != 0)
{
! for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
! {
! if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number)
! break;
! }
! if (qf_idx == qi->qf_listcount)
return FAIL; /* List not found */
}
flags |= QF_GETLIST_ID;
--- 4767,4774 ----
/* For zero, use the current list or the list specifed by 'nr' */
if (di->di_tv.vval.v_number != 0)
{
! qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
! if (qf_idx == -1)
return FAIL; /* List not found */
}
flags |= QF_GETLIST_ID;
***************
*** 5024,5033 ****
/* Use the quickfix/location list with the specified id */
if (di->di_tv.v_type == VAR_NUMBER)
{
! for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
! if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number)
! break;
! if (qf_idx == qi->qf_listcount)
return FAIL; /* List not found */
}
else
--- 5035,5042 ----
/* Use the quickfix/location list with the specified id */
if (di->di_tv.v_type == VAR_NUMBER)
{
! qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
! if (qf_idx == -1)
return FAIL; /* List not found */
}
else
***************
*** 5062,5067 ****
--- 5071,5086 ----
retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
title_save, action == ' ' ? 'a' : action);
+ if (action == 'r')
+ {
+ /*
+ * When replacing the quickfix list entries using
+ * qf_add_entries(), the title is set with a ':' prefix.
+ * Restore the title with the saved title.
+ */
+ vim_free(qi->qf_lists[qf_idx].qf_title);
+ qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
+ }
vim_free(title_save);
}
}
*** ../vim-8.0.1092/src/testdir/test_quickfix.vim 2017-09-02
19:51:40.734765887 +0200
--- src/testdir/test_quickfix.vim 2017-09-11 19:21:15.980697097 +0200
***************
*** 487,492 ****
--- 487,505 ----
" This wipes out the buffer, make sure that doesn't cause trouble.
Xclose
+ if a:cchar == 'l'
+ " When a help window is present, running :lhelpgrep should reuse the
+ " help window and not the current window
+ new | only
+ call g:Xsetlist([], 'f')
+ help index.txt
+ wincmd w
+ lhelpgrep quickfix
+ call assert_equal(1, winnr())
+ call assert_notequal([], getloclist(1))
+ call assert_equal([], getloclist(2))
+ endif
+
new | only
" Search for non existing help string
***************
*** 1684,1689 ****
--- 1697,1706 ----
call assert_equal(' error list 1 of 3; 1 ' . common, res[0])
call assert_equal(' error list 2 of 3; 2 ' . common, res[1])
call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
+
+ call g:Xsetlist([], 'f')
+ let l = split(execute(a:cchar . 'hist'), "\n")
+ call assert_equal('No entries', l[0])
endfunc
func Test_history()
***************
*** 1862,1867 ****
--- 1879,1889 ----
let l = g:Xgetlist({'items':1})
call assert_equal(0, len(l.items))
+ call g:Xsetlist([], 'r', {'title' : 'TestTitle'})
+ call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10,
'text' : 'L10'}]})
+ call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10,
'text' : 'L10'}]})
+ call assert_equal('TestTitle', g:Xgetlist({'title' : 1}).title)
+
" The following used to crash Vim with address sanitizer
call g:Xsetlist([], 'f')
call g:Xsetlist([], 'a', {'items' : [{'filename':'F1', 'lnum':10}]})
***************
*** 1904,1913 ****
call g:Xsetlist([], 'r', l2)
let newl1=g:Xgetlist({'nr':1,'all':1})
let newl2=g:Xgetlist({'nr':2,'all':1})
! call assert_equal(':Fruits', newl1.title)
call assert_equal(['Fruits'], newl1.context)
call assert_equal('Line20', newl1.items[0].text)
! call assert_equal(':Colors', newl2.title)
call assert_equal(['Colors'], newl2.context)
call assert_equal('Line10', newl2.items[0].text)
call g:Xsetlist([], 'f')
--- 1926,1935 ----
call g:Xsetlist([], 'r', l2)
let newl1=g:Xgetlist({'nr':1,'all':1})
let newl2=g:Xgetlist({'nr':2,'all':1})
! call assert_equal('Fruits', newl1.title)
call assert_equal(['Fruits'], newl1.context)
call assert_equal('Line20', newl1.items[0].text)
! call assert_equal('Colors', newl2.title)
call assert_equal(['Colors'], newl2.context)
call assert_equal('Line10', newl2.items[0].text)
call g:Xsetlist([], 'f')
*** ../vim-8.0.1092/src/version.c 2017-09-10 19:13:55.902536551 +0200
--- src/version.c 2017-09-11 19:25:25.179239273 +0200
***************
*** 771,772 ****
--- 771,774 ----
{ /* Add new patch number below this line */
+ /**/
+ 1093,
/**/
--
hundred-and-one symptoms of being an internet addict:
96. On Super Bowl Sunday, you followed the score by going to the
Yahoo main page instead of turning on the TV.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.