diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-03-31 12:55:45 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-03-31 12:59:48 -0400 |
commit | 13f4d4fb6e10ca59a93b1e7ebb56215891b80c2e (patch) | |
tree | de788d46cd03138f759f31f26cdc4b7130226263 | |
parent | 3ae3d80bfb405b6e5a0189a5d93fcc9865c37580 (diff) | |
download | rneovim-13f4d4fb6e10ca59a93b1e7ebb56215891b80c2e.tar.gz rneovim-13f4d4fb6e10ca59a93b1e7ebb56215891b80c2e.tar.bz2 rneovim-13f4d4fb6e10ca59a93b1e7ebb56215891b80c2e.zip |
vim-patch:8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Problem: tag stack is incorrect after CTRL-T and then :tag
Solution: Handle DT_TAG differently. (test by Andy Massimino, closes vim/vim#3944,
closes vim/vim#4177)
https://github.com/vim/vim/commit/7559dcef6cfd0ba13271088fff51b8979fee950b
-rw-r--r-- | src/nvim/tag.c | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_tagjump.vim | 73 |
2 files changed, 80 insertions, 3 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 410b9dfcbd..c609af4751 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -436,11 +436,15 @@ do_tag ( tagmatchname = vim_strsave(name); } - if (type == DT_TAG || type == DT_SELECT || type == DT_JUMP + if (type == DT_SELECT || type == DT_JUMP || type == DT_LTAG) { cur_match = MAXCOL - 1; } - max_num_matches = cur_match + 1; + if (type == DT_TAG) { + max_num_matches = MAXCOL; + } else { + max_num_matches = cur_match + 1; + } /* when the argument starts with '/', use it as a regexp */ if (!no_regexp && *name == '/') { @@ -495,7 +499,7 @@ do_tag ( if (type == DT_CSCOPE && num_matches > 1) { cs_print_tags(); ask_for_selection = true; - } else if (type == DT_TAG) { + } else if (type == DT_TAG && *tag != NUL) { // If a count is supplied to the ":tag <name>" command, then // jump to count'th matching tag. cur_match = count > 0 ? count - 1 : 0; diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index f9bd8b5246..180738a7c9 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -258,4 +258,77 @@ func Test_tagjump_etags() bwipe! endfunc +func Test_tag_with_count() + call writefile([ + \ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()', + \ ], 'Xtags') + call writefile([ + \ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()', + \ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()', + \ ], 'Ytags') + cal writefile([ + \ 'int main()', + \ 'void test()', + \ ], 'Xtest.c') + cal writefile([ + \ 'void test();', + \ ], 'Xtest.h') + set tags=Xtags,Ytags + + new Xtest.c + let tl = taglist('test', 'Xtest.c') + call assert_equal(tl[0].filename, 'Xtest.c') + call assert_equal(tl[1].filename, 'Xtest.h') + + tag test + call assert_equal(bufname('%'), 'Xtest.c') + 1tag test + call assert_equal(bufname('%'), 'Xtest.c') + 2tag test + call assert_equal(bufname('%'), 'Xtest.h') + + set tags& + call delete('Xtags') + call delete('Ytags') + bwipe Xtest.h + bwipe Xtest.c + call delete('Xtest.h') + call delete('Xtest.c') +endfunc + +func Test_tagnr_recall() + call writefile([ + \ 'test Xtest.h /^void test();$/;" p', + \ 'main Xtest.c /^int main()$/;" f', + \ 'test Xtest.c /^void test()$/;" f', + \ ], 'Xtags') + cal writefile([ + \ 'int main()', + \ 'void test()', + \ ], 'Xtest.c') + cal writefile([ + \ 'void test();', + \ ], 'Xtest.h') + set tags=Xtags + + new Xtest.c + let tl = taglist('test', 'Xtest.c') + call assert_equal(tl[0].filename, 'Xtest.c') + call assert_equal(tl[1].filename, 'Xtest.h') + + 2tag test + call assert_equal(bufname('%'), 'Xtest.h') + pop + call assert_equal(bufname('%'), 'Xtest.c') + tag + call assert_equal(bufname('%'), 'Xtest.h') + + set tag& + call delete('Xtags') + bwipe Xtest.h + bwipe Xtest.c + call delete('Xtest.h') + call delete('Xtest.c') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |