mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 13:10:44 +00:00
@@ -2291,7 +2291,7 @@ tabpagebuflist([{arg}]) List list of buffer numbers in tab page
|
|||||||
tabpagenr([{arg}]) Number number of current or last tab page
|
tabpagenr([{arg}]) Number number of current or last tab page
|
||||||
tabpagewinnr({tabarg}[, {arg}])
|
tabpagewinnr({tabarg}[, {arg}])
|
||||||
Number number of current window in tab page
|
Number number of current window in tab page
|
||||||
taglist({expr}) List list of tags matching {expr}
|
taglist({expr}[, {filename}]) List list of tags matching {expr}
|
||||||
tagfiles() List tags files used
|
tagfiles() List tags files used
|
||||||
tan({expr}) Float tangent of {expr}
|
tan({expr}) Float tangent of {expr}
|
||||||
tanh({expr}) Float hyperbolic tangent of {expr}
|
tanh({expr}) Float hyperbolic tangent of {expr}
|
||||||
@@ -7427,8 +7427,13 @@ tagfiles() Returns a |List| with the file names used to search for tags
|
|||||||
for the current buffer. This is the 'tags' option expanded.
|
for the current buffer. This is the 'tags' option expanded.
|
||||||
|
|
||||||
|
|
||||||
taglist({expr}) *taglist()*
|
taglist({expr}[, {filename}]) *taglist()*
|
||||||
Returns a list of tags matching the regular expression {expr}.
|
Returns a list of tags matching the regular expression {expr}.
|
||||||
|
|
||||||
|
If {filename} is passed it is used to prioritize the results
|
||||||
|
in the same way that |:tselect| does. See |tag-priority|.
|
||||||
|
{filename} should be the full path of the file.
|
||||||
|
|
||||||
Each list item is a dictionary with at least the following
|
Each list item is a dictionary with at least the following
|
||||||
entries:
|
entries:
|
||||||
name Name of the tag.
|
name Name of the tag.
|
||||||
|
|||||||
@@ -8728,10 +8728,10 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
fold_count = foldedCount(curwin, lnum, &foldinfo);
|
fold_count = foldedCount(curwin, lnum, &foldinfo);
|
||||||
if (fold_count > 0) {
|
if (fold_count > 0) {
|
||||||
text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
|
text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf);
|
||||||
&foldinfo, buf);
|
if (text == buf) {
|
||||||
if (text == buf)
|
|
||||||
text = vim_strsave(text);
|
text = vim_strsave(text);
|
||||||
|
}
|
||||||
rettv->vval.v_string = text;
|
rettv->vval.v_string = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16436,7 +16436,12 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern);
|
const char *fname = NULL;
|
||||||
|
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||||
|
fname = tv_get_string(&argvars[1]);
|
||||||
|
}
|
||||||
|
(void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern,
|
||||||
|
(char_u *)fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ return {
|
|||||||
tabpagenr={args={0, 1}},
|
tabpagenr={args={0, 1}},
|
||||||
tabpagewinnr={args={1, 2}},
|
tabpagewinnr={args={1, 2}},
|
||||||
tagfiles={},
|
tagfiles={},
|
||||||
taglist={args=1},
|
taglist={args={1, 2}},
|
||||||
tan={args=1, func="float_op_wrapper", data="&tan"},
|
tan={args=1, func="float_op_wrapper", data="&tan"},
|
||||||
tanh={args=1, func="float_op_wrapper", data="&tanh"},
|
tanh={args=1, func="float_op_wrapper", data="&tanh"},
|
||||||
tempname={},
|
tempname={},
|
||||||
|
|||||||
@@ -1847,14 +1847,14 @@ parse_line:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#define TAG_SEP 0x01
|
#define TAG_SEP 0x02
|
||||||
size_t tag_fname_len = STRLEN(tag_fname);
|
size_t tag_fname_len = STRLEN(tag_fname);
|
||||||
// Save the tag in a buffer.
|
// Save the tag in a buffer.
|
||||||
// Use 0x01 to separate fields (Can't use NUL, because the
|
// Use 0x02 to separate fields (Can't use NUL, because the
|
||||||
// hash key is terminated by NUL).
|
// hash key is terminated by NUL).
|
||||||
// Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf>
|
// Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL>
|
||||||
// other tag: <mtt><tag_fname><NUL><NUL><lbuf>
|
// other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL>
|
||||||
// without Emacs tags: <mtt><tag_fname><NUL><lbuf>
|
// without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL>
|
||||||
// Here <mtt> is the "mtt" value plus 1 to avoid NUL.
|
// Here <mtt> is the "mtt" value plus 1 to avoid NUL.
|
||||||
len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3;
|
len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3;
|
||||||
mfp = xmalloc(sizeof(char_u) + len + 1);
|
mfp = xmalloc(sizeof(char_u) + len + 1);
|
||||||
@@ -2797,11 +2797,9 @@ add_tag_field (
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Add the tags matching the specified pattern "pat" to the list "list"
|
||||||
* Add the tags matching the specified pattern to the list "list"
|
/// as a dictionary. Use "buf_fname" for priority, unless NULL.
|
||||||
* as a dictionary
|
int get_tags(list_T *list, char_u *pat, char_u *buf_fname)
|
||||||
*/
|
|
||||||
int get_tags(list_T *list, char_u *pat)
|
|
||||||
{
|
{
|
||||||
int num_matches, i, ret;
|
int num_matches, i, ret;
|
||||||
char_u **matches, *p;
|
char_u **matches, *p;
|
||||||
@@ -2811,7 +2809,7 @@ int get_tags(list_T *list, char_u *pat)
|
|||||||
bool is_static;
|
bool is_static;
|
||||||
|
|
||||||
ret = find_tags(pat, &num_matches, &matches,
|
ret = find_tags(pat, &num_matches, &matches,
|
||||||
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
|
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);
|
||||||
if (ret == OK && num_matches > 0) {
|
if (ret == OK && num_matches > 0) {
|
||||||
for (i = 0; i < num_matches; ++i) {
|
for (i = 0; i < num_matches; ++i) {
|
||||||
int parse_result = parse_match(matches[i], &tp);
|
int parse_result = parse_match(matches[i], &tp);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ source test_tabline.vim
|
|||||||
" source test_tabpage.vim
|
" source test_tabpage.vim
|
||||||
source test_tagcase.vim
|
source test_tagcase.vim
|
||||||
source test_tagjump.vim
|
source test_tagjump.vim
|
||||||
|
source test_taglist.vim
|
||||||
source test_true_false.vim
|
source test_true_false.vim
|
||||||
source test_unlet.vim
|
source test_unlet.vim
|
||||||
source test_utf8.vim
|
source test_utf8.vim
|
||||||
|
|||||||
58
src/nvim/testdir/test_taglist.vim
Normal file
58
src/nvim/testdir/test_taglist.vim
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
" test 'taglist' function
|
||||||
|
|
||||||
|
func Test_taglist()
|
||||||
|
call writefile([
|
||||||
|
\ "FFoo\tXfoo\t1",
|
||||||
|
\ "FBar\tXfoo\t2",
|
||||||
|
\ "BFoo\tXbar\t1",
|
||||||
|
\ "BBar\tXbar\t2"
|
||||||
|
\ ], 'Xtags')
|
||||||
|
set tags=Xtags
|
||||||
|
split Xtext
|
||||||
|
|
||||||
|
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
|
||||||
|
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xtext"), {i, v -> v.name}))
|
||||||
|
call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
|
||||||
|
call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
|
||||||
|
|
||||||
|
call delete('Xtags')
|
||||||
|
bwipe
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_taglist_native_etags()
|
||||||
|
if !has('emacs_tags')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call writefile([
|
||||||
|
\ "\x0c",
|
||||||
|
\ "src/os_unix.c,13491",
|
||||||
|
\ "set_signals(\x7f1335,32699",
|
||||||
|
\ "reset_signals(\x7f1407,34136",
|
||||||
|
\ ], 'Xtags')
|
||||||
|
|
||||||
|
set tags=Xtags
|
||||||
|
|
||||||
|
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
|
||||||
|
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
|
||||||
|
|
||||||
|
call delete('Xtags')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_taglist_ctags_etags()
|
||||||
|
if !has('emacs_tags')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call writefile([
|
||||||
|
\ "\x0c",
|
||||||
|
\ "src/os_unix.c,13491",
|
||||||
|
\ "set_signals(void)\x7fset_signals\x011335,32699",
|
||||||
|
\ "reset_signals(void)\x7freset_signals\x011407,34136",
|
||||||
|
\ ], 'Xtags')
|
||||||
|
|
||||||
|
set tags=Xtags
|
||||||
|
|
||||||
|
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
|
||||||
|
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
|
||||||
|
|
||||||
|
call delete('Xtags')
|
||||||
|
endfunc
|
||||||
Reference in New Issue
Block a user