Skip to content

Commit a39ae49

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents d97f02d + 4889ad7 commit a39ae49

File tree

10 files changed

+84
-38
lines changed

10 files changed

+84
-38
lines changed

runtime/doc/eval.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,7 @@ systemlist({expr} [, {input}]) List output of shell command/filter {expr}
23632363
tabpagebuflist([{arg}]) List list of buffer numbers in tab page
23642364
tabpagenr([{arg}]) Number number of current or last tab page
23652365
tabpagewinnr({tabarg}[, {arg}]) Number number of current window in tab page
2366-
taglist({expr}) List list of tags matching {expr}
2366+
taglist({expr}[, {filename}]) List list of tags matching {expr}
23672367
tagfiles() List tags files used
23682368
tan({expr}) Float tangent of {expr}
23692369
tanh({expr}) Float hyperbolic tangent of {expr}
@@ -7741,8 +7741,13 @@ tagfiles() Returns a |List| with the file names used to search for tags
77417741
for the current buffer. This is the 'tags' option expanded.
77427742

77437743

7744-
taglist({expr}) *taglist()*
7744+
taglist({expr}[, {filename}]) *taglist()*
77457745
Returns a list of tags matching the regular expression {expr}.
7746+
7747+
If {filename} is passed it is used to prioritize the results
7748+
in the same way that |:tselect| does. See |tag-priority|.
7749+
{filename} should be the full path of the file.
7750+
77467751
Each list item is a dictionary with at least the following
77477752
entries:
77487753
name Name of the tag.

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,7 @@ test_arglist \
22302230
test_tabpage \
22312231
test_tagcase \
22322232
test_tagjump \
2233+
test_taglist \
22332234
test_tcl \
22342235
test_textobjects \
22352236
test_timers \

src/evalfunc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ static struct fst
824824
{"tabpagenr", 0, 1, f_tabpagenr},
825825
{"tabpagewinnr", 1, 2, f_tabpagewinnr},
826826
{"tagfiles", 0, 0, f_tagfiles},
827-
{"taglist", 1, 1, f_taglist},
827+
{"taglist", 1, 2, f_taglist},
828828
#ifdef FEAT_FLOAT
829829
{"tan", 1, 1, f_tan},
830830
{"tanh", 1, 1, f_tanh},
@@ -3589,7 +3589,8 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
35893589
fold_count = foldedCount(curwin, lnum, &foldinfo);
35903590
if (fold_count > 0)
35913591
{
3592-
text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf);
3592+
text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
3593+
&foldinfo, buf);
35933594
if (text == buf)
35943595
text = vim_strsave(text);
35953596
rettv->vval.v_string = text;
@@ -12294,6 +12295,7 @@ f_tagfiles(typval_T *argvars UNUSED, typval_T *rettv)
1229412295
static void
1229512296
f_taglist(typval_T *argvars, typval_T *rettv)
1229612297
{
12298+
char_u *fname = NULL;
1229712299
char_u *tag_pattern;
1229812300

1229912301
tag_pattern = get_tv_string(&argvars[0]);
@@ -12302,8 +12304,10 @@ f_taglist(typval_T *argvars, typval_T *rettv)
1230212304
if (*tag_pattern == NUL)
1230312305
return;
1230412306

12307+
if (argvars[1].v_type != VAR_UNKNOWN)
12308+
fname = get_tv_string(&argvars[1]);
1230512309
if (rettv_list_alloc(rettv) == OK)
12306-
(void)get_tags(rettv->vval.v_list, tag_pattern);
12310+
(void)get_tags(rettv->vval.v_list, tag_pattern, fname);
1230712311
}
1230812312

1230912313
/*

src/proto/tag.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf);
88
void tagname_free(tagname_T *tnp);
99
void simplify_filename(char_u *filename);
1010
int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file);
11-
int get_tags(list_T *list, char_u *pat);
11+
int get_tags(list_T *list, char_u *pat, char_u *buf_fname);
1212
/* vim: set ft=c : */

src/tag.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,11 +3876,11 @@ add_tag_field(
38763876
}
38773877

38783878
/*
3879-
* Add the tags matching the specified pattern to the list "list"
3880-
* as a dictionary
3879+
* Add the tags matching the specified pattern "pat" to the list "list"
3880+
* as a dictionary. Use "buf_fname" for priority, unless NULL.
38813881
*/
38823882
int
3883-
get_tags(list_T *list, char_u *pat)
3883+
get_tags(list_T *list, char_u *pat, char_u *buf_fname)
38843884
{
38853885
int num_matches, i, ret;
38863886
char_u **matches, *p;
@@ -3890,7 +3890,7 @@ get_tags(list_T *list, char_u *pat)
38903890
long is_static;
38913891

38923892
ret = find_tags(pat, &num_matches, &matches,
3893-
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
3893+
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);
38943894
if (ret == OK && num_matches > 0)
38953895
{
38963896
for (i = 0; i < num_matches; ++i)

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ source test_tabline.vim
4747
source test_tabpage.vim
4848
source test_tagcase.vim
4949
source test_tagjump.vim
50+
source test_taglist.vim
5051
source test_timers.vim
5152
source test_true_false.vim
5253
source test_unlet.vim

src/testdir/test_autocmd.vim

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ func Test_BufEnter()
340340
call mkdir('Xdir')
341341
split Xdir
342342
call assert_equal('+++', g:val)
343-
bwipe!
343+
344+
" On MS-Windows we can't edit the directory, make sure we wipe the right
345+
" buffer.
346+
bwipe! Xdir
344347

345348
call delete('Xdir', 'd')
346349
au! BufEnter
@@ -349,40 +352,37 @@ endfunc
349352
" Closing a window might cause an endless loop
350353
" E814 for older Vims
351354
function Test_autocmd_bufwipe_in_SessLoadPost()
352-
if has('win32')
353-
throw 'Skipped: test hangs on MS-Windows'
354-
endif
355355
tabnew
356356
set noswapfile
357-
let g:bufnr=bufnr('%')
358357
mksession!
359358

360-
let content=['set nocp noswapfile',
359+
let content = ['set nocp noswapfile',
361360
\ 'let v:swapchoice="e"',
362361
\ 'augroup test_autocmd_sessionload',
363362
\ 'autocmd!',
364363
\ 'autocmd SessionLoadPost * 4bw!',
365-
\ 'augroup END'
364+
\ 'augroup END',
365+
\ '',
366+
\ 'func WriteErrors()',
367+
\ ' call writefile([execute("messages")], "Xerrors")',
368+
\ 'endfunc',
369+
\ 'au VimLeave * call WriteErrors()',
366370
\ ]
367371
call writefile(content, 'Xvimrc')
368-
let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim')
369-
call assert_match('E814', a)
372+
call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
373+
let errors = join(readfile('Xerrors'))
374+
call assert_match('E814', errors)
370375

371-
unlet! g:bufnr
372376
set swapfile
373-
for file in ['Session.vim', 'Xvimrc']
377+
for file in ['Session.vim', 'Xvimrc', 'Xerrors']
374378
call delete(file)
375379
endfor
376380
endfunc
377381

378382
" SEGV occurs in older versions.
379383
function Test_autocmd_bufwipe_in_SessLoadPost2()
380-
if has('win32')
381-
throw 'Skipped: test hangs on MS-Windows'
382-
endif
383384
tabnew
384385
set noswapfile
385-
let g:bufnr=bufnr('%')
386386
mksession!
387387

388388
let content = ['set nocp noswapfile',
@@ -397,20 +397,24 @@ function Test_autocmd_bufwipe_in_SessLoadPost2()
397397
\ ' exec ''bwipeout '' . b',
398398
\ ' endif',
399399
\ ' endfor',
400-
\ 'call append("1", "SessionLoadPost DONE")',
400+
\ ' echomsg "SessionLoadPost DONE"',
401401
\ 'endfunction',
402-
\ 'au SessionLoadPost * call DeleteInactiveBufs()']
402+
\ 'au SessionLoadPost * call DeleteInactiveBufs()',
403+
\ '',
404+
\ 'func WriteErrors()',
405+
\ ' call writefile([execute("messages")], "Xerrors")',
406+
\ 'endfunc',
407+
\ 'au VimLeave * call WriteErrors()',
408+
\ ]
403409
call writefile(content, 'Xvimrc')
404-
let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim')
405-
" this probably only matches on unix
406-
if has("unix")
407-
call assert_notmatch('Caught deadly signal SEGV', a)
408-
endif
409-
call assert_match('SessionLoadPost DONE', a)
410-
411-
unlet! g:bufnr
410+
call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
411+
let errors = join(readfile('Xerrors'))
412+
" This probably only ever matches on unix.
413+
call assert_notmatch('Caught deadly signal SEGV', errors)
414+
call assert_match('SessionLoadPost DONE', errors)
415+
412416
set swapfile
413-
for file in ['Session.vim', 'Xvimrc']
417+
for file in ['Session.vim', 'Xvimrc', 'Xerrors']
414418
call delete(file)
415419
endfor
416420
endfunc

src/testdir/test_quotestar.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func Do_test_quotestar_for_x11()
5353
call WaitFor('serverlist() =~ "' . name . '"')
5454
call assert_match(name, serverlist())
5555

56+
" Wait for the server to be up and answering requests. One second is not
57+
" always sufficient.
58+
call WaitFor('remote_expr("' . name . '", "v:version", "", 2) != ""')
59+
5660
" Clear the *-register of this vim instance.
5761
let @* = ''
5862

@@ -78,8 +82,8 @@ func Do_test_quotestar_for_x11()
7882
else
7983
call remote_send(name, ":gui -f\<CR>")
8084
endif
81-
" Wait for the server to be up and answering requests.
82-
call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""')
85+
" Wait for the server in the GUI to be up and answering requests.
86+
call WaitFor('remote_expr("' . name . '", "has(\"gui_running\")", "", 1) =~ "1"')
8387

8488
call remote_send(name, ":let @* = 'maybe'\<CR>")
8589
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"')

src/testdir/test_taglist.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
" test 'taglist' function
2+
3+
func Test_taglist()
4+
call writefile([
5+
\ "FFoo\tXfoo\t1",
6+
\ "FBar\tXfoo\t2",
7+
\ "BFoo\tXbar\t1",
8+
\ "BBar\tXbar\t2"
9+
\ ], 'Xtags')
10+
set tags=Xtags
11+
split Xtext
12+
13+
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
14+
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name}))
15+
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
16+
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
17+
18+
call delete('Xtags')
19+
bwipe
20+
endfunc
21+

src/version.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,12 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
500,
784+
/**/
785+
499,
786+
/**/
787+
498,
782788
/**/
783789
497,
784790
/**/

0 commit comments

Comments
 (0)