aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-22 05:35:21 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-05-22 06:37:26 +0800
commit59fe8ffdeaacc08b811aa97d270daec6d6ed2769 (patch)
tree6a9e75cb83c78c1828ef96fda8d6b1a607a461d3
parentb86381f425223adf0ff91fa0746914a5774ddabb (diff)
downloadrneovim-59fe8ffdeaacc08b811aa97d270daec6d6ed2769.tar.gz
rneovim-59fe8ffdeaacc08b811aa97d270daec6d6ed2769.tar.bz2
rneovim-59fe8ffdeaacc08b811aa97d270daec6d6ed2769.zip
vim-patch:9.1.0428: Tag guessing leaves wrong search history with very short names
Problem: Tag guessing leaves wrong search history with very short names (after 9.1.0426). Solution: Use the correct variable for pattern length (zeertzjq). closes: vim/vim#14817 https://github.com/vim/vim/commit/42cd192daa4b7f29131c7be1beaecb6067e96266 Cherry-pick Test_tagbsearch() changes from patch 9.0.0767.
-rw-r--r--src/nvim/tag.c2
-rw-r--r--test/old/testdir/test_tagjump.vim24
2 files changed, 21 insertions, 5 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index f322438485..e7f483dd3d 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -2978,7 +2978,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
// Guess again: "^char * \<func ("
pbuflen = (size_t)snprintf(pbuf, LSIZE, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
tagp.tagname);
- if (!do_search(NULL, '/', '/', pbuf, len, 1, search_options, NULL)) {
+ if (!do_search(NULL, '/', '/', pbuf, pbuflen, 1, search_options, NULL)) {
found = 0;
}
}
diff --git a/test/old/testdir/test_tagjump.vim b/test/old/testdir/test_tagjump.vim
index ff1110e070..a614c19ce2 100644
--- a/test/old/testdir/test_tagjump.vim
+++ b/test/old/testdir/test_tagjump.vim
@@ -1551,14 +1551,14 @@ func Test_tagbsearch()
\ "third\tXfoo\t3",
\ "second\tXfoo\t2",
\ "first\tXfoo\t1"],
- \ 'Xtags')
+ \ 'Xtags', 'D')
set tags=Xtags
let code =<< trim [CODE]
int first() {}
int second() {}
int third() {}
[CODE]
- call writefile(code, 'Xfoo')
+ call writefile(code, 'Xfoo', 'D')
enew
set tagbsearch
@@ -1618,9 +1618,25 @@ func Test_tagbsearch()
\ 'Xtags')
call assert_fails('tag bbb', 'E426:')
- call delete('Xtags')
- call delete('Xfoo')
set tags& tagbsearch&
endfunc
+" Test tag guessing with very short names
+func Test_tag_guess_short()
+ call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
+ \ "y\tXf\t/^y()/"],
+ \ 'Xt', 'D')
+ set tags=Xt cpoptions+=t
+ call writefile(['', 'int * y () {}', ''], 'Xf', 'D')
+
+ let v:statusmsg = ''
+ let @/ = ''
+ ta y
+ call assert_match('E435:', v:statusmsg)
+ call assert_equal(2, line('.'))
+ call assert_match('<y', @/)
+
+ set tags& cpoptions-=t
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab