Skip to content

Commit b4d5fba

Browse files
committed
patch 8.0.1093: various small quickfix issues
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)
1 parent 45d5f26 commit b4d5fba

File tree

7 files changed

+90
-32
lines changed

7 files changed

+90
-32
lines changed

runtime/doc/eval.txt

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.0. Last change: 2017 Aug 13
1+
*eval.txt* For Vim version 8.0. Last change: 2017 Sep 11
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1449,7 +1449,7 @@ v:beval_text The text under or after the mouse pointer. Usually a word as
14491449
but a dot and "->" before the position is included. When on a
14501450
']' the text before it is used, including the matching '[' and
14511451
word before it. When on a Visual area within one line the
1452-
highlighted text is used.
1452+
highlighted text is used. Also see |<cexpr>|.
14531453
Only valid while evaluating the 'balloonexpr' option.
14541454

14551455
*v:beval_winnr* *beval_winnr-variable*
@@ -3301,7 +3301,7 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()*
33013301
When {ic} is given and it's |TRUE| then case is ignored.
33023302

33033303
When {comp} is a string then the number of not overlapping
3304-
occurences of {expr} is returned.
3304+
occurrences of {expr} is returned.
33053305

33063306

33073307
*cscope_connection()*
@@ -3467,7 +3467,7 @@ escape({string}, {chars}) *escape()*
34673467
:echo escape('c:\program files\vim', ' \')
34683468
< results in: >
34693469
c:\\program\ files\\vim
3470-
< Also see |shellescape()|.
3470+
< Also see |shellescape()| and |fnameescape()|.
34713471

34723472
*eval()*
34733473
eval({string}) Evaluate {string} and return the result. Especially useful to
@@ -3887,7 +3887,7 @@ float2nr({expr}) *float2nr()*
38873887
When the value of {expr} is out of range for a |Number| the
38883888
result is truncated to 0x7fffffff or -0x7fffffff (or when
38893889
64-bit Number support is enabled, 0x7fffffffffffffff or
3890-
-0x7fffffffffffffff. NaN results in -0x80000000 (or when
3890+
-0x7fffffffffffffff). NaN results in -0x80000000 (or when
38913891
64-bit Number support is enabled, -0x8000000000000000).
38923892
Examples: >
38933893
echo float2nr(3.95)
@@ -4657,12 +4657,12 @@ getqflist([{what}]) *getqflist()*
46574657
If "nr" is not present then the current quickfix list is used.
46584658
If both "nr" and a non-zero "id" are specified, then the list
46594659
specified by "id" is used.
4660-
To get the number of lists in the quickfix stack, set 'nr' to
4661-
'$' in {what}. The 'nr' value in the returned dictionary
4660+
To get the number of lists in the quickfix stack, set "nr" to
4661+
"$" in {what}. The "nr" value in the returned dictionary
46624662
contains the quickfix stack size.
4663-
When 'text' is specified, all the other items are ignored. The
4664-
returned dictionary contains the entry 'items' with the list
4665-
of entries.
4663+
When "lines" is specified, all the other items except "efm"
4664+
are ignored. The returned dictionary contains the entry
4665+
"items" with the list of entries.
46664666
In case of error processing {what}, an empty dictionary is
46674667
returned.
46684668

@@ -6967,6 +6967,7 @@ setline({lnum}, {text}) *setline()*
69676967
:for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
69686968
: call setline(n, l)
69696969
:endfor
6970+
69706971
< Note: The '[ and '] marks are not set.
69716972

69726973
setloclist({nr}, {list}[, {action}[, {what}]]) *setloclist()*
@@ -7164,16 +7165,17 @@ setreg({regname}, {value} [, {options}])
71647165
:call setreg('a', "1\n2\n3", 'b5')
71657166
71667167
< This example shows using the functions to save and restore a
7167-
register (note: you may not reliably restore register value
7168-
without using the third argument to |getreg()| as without it
7169-
newlines are represented as newlines AND Nul bytes are
7170-
represented as newlines as well, see |NL-used-for-Nul|). >
7168+
register: >
71717169
:let var_a = getreg('a', 1, 1)
71727170
:let var_amode = getregtype('a')
71737171
....
71747172
:call setreg('a', var_a, var_amode)
7173+
< Note: you may not reliably restore register value
7174+
without using the third argument to |getreg()| as without it
7175+
newlines are represented as newlines AND Nul bytes are
7176+
represented as newlines as well, see |NL-used-for-Nul|.
71757177

7176-
< You can also change the type of a register by appending
7178+
You can also change the type of a register by appending
71777179
nothing: >
71787180
:call setreg('a', '', 'al')
71797181
@@ -8145,7 +8147,7 @@ term_start({cmd}, {options}) *term_start()*
81458147
are supported:
81468148
all timeout options
81478149
"stoponexit"
8148-
"out_cb", "err_cb"
8150+
"callback", "out_cb", "err_cb"
81498151
"exit_cb", "close_cb"
81508152
"in_io", "in_top", "in_bot", "in_name", "in_buf"
81518153
"out_io", "out_name", "out_buf", "out_modifiable", "out_msg"
@@ -8165,6 +8167,7 @@ term_start({cmd}, {options}) *term_start()*
81658167
"curwin" use the current window, do not split the
81668168
window; fails if the current buffer
81678169
cannot be |abandon|ed
8170+
"hidden" do not open a window
81688171
"term_finish" What to do when the job is finished:
81698172
"close": close any windows
81708173
"open": open window if needed
@@ -8562,7 +8565,7 @@ win_getid([{win} [, {tab}]]) *win_getid()*
85628565
Get the |window-ID| for the specified window.
85638566
When {win} is missing use the current window.
85648567
With {win} this is the window number. The top window has
8565-
number 1.
8568+
number 1. Use `win_getid(winnr())` for the current window.
85668569
Without {tab} use the current tab, otherwise the tab with
85678570
number {tab}. The first tab has number one.
85688571
Return zero if the window cannot be found.

runtime/doc/quickfix.txt

+12
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ From inside Vim an easy way to run a command and handle the output is with the
4444
The 'errorformat' option should be set to match the error messages from your
4545
compiler (see |errorformat| below).
4646

47+
*quickfix-ID*
48+
Each quickfix list has a unique identifier called the quickfix ID and this
49+
number will not change within a Vim session. The getqflist() function can be
50+
used to get the identifier assigned to a list.
51+
52+
*quickfix-ID*
53+
Each quickfix list has a unique identifier called the quickfix ID and this
54+
number will not change within a Vim session. The getqflist() function can be
55+
used to get the identifier assigned to a list. There is also a quickfix list
56+
number which may change whenever more than ten lists are added to a quickfix
57+
stack.
58+
4759
*location-list* *E776*
4860
A location list is a window-local quickfix list. You get one after commands
4961
like `:lvimgrep`, `:lgrep`, `:lhelpgrep`, `:lmake`, etc., which create a

src/evalfunc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4826,7 +4826,7 @@ get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv)
48264826
dict_T *d = what_arg->vval.v_dict;
48274827

48284828
if (d != NULL)
4829-
get_errorlist_properties(wp, d, rettv->vval.v_dict);
4829+
qf_get_properties(wp, d, rettv->vval.v_dict);
48304830
}
48314831
else
48324832
EMSG(_(e_dictreq));

src/proto/quickfix.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void ex_cnext(exarg_T *eap);
2222
void ex_cfile(exarg_T *eap);
2323
void ex_vimgrep(exarg_T *eap);
2424
int get_errorlist(qf_info_T *qi, win_T *wp, int qf_idx, list_T *list);
25-
int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict);
25+
int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict);
2626
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, dict_T *what);
2727
int set_ref_in_quickfix(int copyID);
2828
void ex_cbuffer(exarg_T *eap);

src/quickfix.c

+30-11
Original file line numberDiff line numberDiff line change
@@ -4690,13 +4690,28 @@ qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
46904690
return status;
46914691
}
46924692

4693+
/*
4694+
* Return the quickfix/location list number with the given identifier.
4695+
* Returns -1 if list is not found.
4696+
*/
4697+
static int
4698+
qf_id2nr(qf_info_T *qi, int_u qfid)
4699+
{
4700+
int qf_idx;
4701+
4702+
for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
4703+
if (qi->qf_lists[qf_idx].qf_id == qfid)
4704+
return qf_idx;
4705+
return -1;
4706+
}
4707+
46934708
/*
46944709
* Return quickfix/location list details (title) as a
46954710
* dictionary. 'what' contains the details to return. If 'list_idx' is -1,
46964711
* then current list is used. Otherwise the specified list is used.
46974712
*/
46984713
int
4699-
get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
4714+
qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
47004715
{
47014716
qf_info_T *qi = &ql_info;
47024717
int status = OK;
@@ -4752,12 +4767,8 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
47524767
/* For zero, use the current list or the list specifed by 'nr' */
47534768
if (di->di_tv.vval.v_number != 0)
47544769
{
4755-
for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
4756-
{
4757-
if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number)
4758-
break;
4759-
}
4760-
if (qf_idx == qi->qf_listcount)
4770+
qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
4771+
if (qf_idx == -1)
47614772
return FAIL; /* List not found */
47624773
}
47634774
flags |= QF_GETLIST_ID;
@@ -5024,10 +5035,8 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
50245035
/* Use the quickfix/location list with the specified id */
50255036
if (di->di_tv.v_type == VAR_NUMBER)
50265037
{
5027-
for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
5028-
if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number)
5029-
break;
5030-
if (qf_idx == qi->qf_listcount)
5038+
qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
5039+
if (qf_idx == -1)
50315040
return FAIL; /* List not found */
50325041
}
50335042
else
@@ -5062,6 +5071,16 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
50625071

50635072
retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
50645073
title_save, action == ' ' ? 'a' : action);
5074+
if (action == 'r')
5075+
{
5076+
/*
5077+
* When replacing the quickfix list entries using
5078+
* qf_add_entries(), the title is set with a ':' prefix.
5079+
* Restore the title with the saved title.
5080+
*/
5081+
vim_free(qi->qf_lists[qf_idx].qf_title);
5082+
qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
5083+
}
50655084
vim_free(title_save);
50665085
}
50675086
}

src/testdir/test_quickfix.vim

+24-2
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,19 @@ func s:test_xhelpgrep(cchar)
487487
" This wipes out the buffer, make sure that doesn't cause trouble.
488488
Xclose
489489

490+
if a:cchar == 'l'
491+
" When a help window is present, running :lhelpgrep should reuse the
492+
" help window and not the current window
493+
new | only
494+
call g:Xsetlist([], 'f')
495+
help index.txt
496+
wincmd w
497+
lhelpgrep quickfix
498+
call assert_equal(1, winnr())
499+
call assert_notequal([], getloclist(1))
500+
call assert_equal([], getloclist(2))
501+
endif
502+
490503
new | only
491504

492505
" Search for non existing help string
@@ -1684,6 +1697,10 @@ func HistoryTest(cchar)
16841697
call assert_equal(' error list 1 of 3; 1 ' . common, res[0])
16851698
call assert_equal(' error list 2 of 3; 2 ' . common, res[1])
16861699
call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
1700+
1701+
call g:Xsetlist([], 'f')
1702+
let l = split(execute(a:cchar . 'hist'), "\n")
1703+
call assert_equal('No entries', l[0])
16871704
endfunc
16881705

16891706
func Test_history()
@@ -1862,6 +1879,11 @@ func Xproperty_tests(cchar)
18621879
let l = g:Xgetlist({'items':1})
18631880
call assert_equal(0, len(l.items))
18641881

1882+
call g:Xsetlist([], 'r', {'title' : 'TestTitle'})
1883+
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10, 'text' : 'L10'}]})
1884+
call g:Xsetlist([], 'r', {'items' : [{'filename' : 'F1', 'lnum' : 10, 'text' : 'L10'}]})
1885+
call assert_equal('TestTitle', g:Xgetlist({'title' : 1}).title)
1886+
18651887
" The following used to crash Vim with address sanitizer
18661888
call g:Xsetlist([], 'f')
18671889
call g:Xsetlist([], 'a', {'items' : [{'filename':'F1', 'lnum':10}]})
@@ -1904,10 +1926,10 @@ func Xproperty_tests(cchar)
19041926
call g:Xsetlist([], 'r', l2)
19051927
let newl1=g:Xgetlist({'nr':1,'all':1})
19061928
let newl2=g:Xgetlist({'nr':2,'all':1})
1907-
call assert_equal(':Fruits', newl1.title)
1929+
call assert_equal('Fruits', newl1.title)
19081930
call assert_equal(['Fruits'], newl1.context)
19091931
call assert_equal('Line20', newl1.items[0].text)
1910-
call assert_equal(':Colors', newl2.title)
1932+
call assert_equal('Colors', newl2.title)
19111933
call assert_equal(['Colors'], newl2.context)
19121934
call assert_equal('Line10', newl2.items[0].text)
19131935
call g:Xsetlist([], 'f')

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1093,
772774
/**/
773775
1092,
774776
/**/

0 commit comments

Comments
 (0)