]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0428: Tag guessing leaves wrong search history with very short names v9.1.0428
authorzeertzjq <zeertzjq@outlook.com>
Tue, 21 May 2024 15:19:58 +0000 (17:19 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 21 May 2024 15:19:58 +0000 (17:19 +0200)
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: #14817

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/tag.c
src/testdir/test_tagjump.vim
src/version.c

index 87ff802c741ad2c2a1b641dd9627fdaf62b9d525..d406fdec1a3e43ebe8a8bc4f37f0800ac3e7100c 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -3945,7 +3945,7 @@ jumpto_tag(
                        // Guess again: "^char * \<func  ("
                        pbuflen = vim_snprintf((char *)pbuf, LSIZE, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
                                                                tagp.tagname);
-                       if (!do_search(NULL, '/', '/', pbuf, len, (long)1,
+                       if (!do_search(NULL, '/', '/', pbuf, pbuflen, (long)1,
                                                         search_options, NULL))
                            found = 0;
                    }
index 2abf1f65953cf4d6c9fd5318fa21f9a68355f604..432906efbfbf23bbcefcdcf0e1a823dc3ec23414 100644 (file)
@@ -1560,4 +1560,22 @@ func Test_tagbsearch()
   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
index 7d3a7e570d12f7818e43417bdaded9ea14d19b0b..acec967b8fdfbb3a211ae961ea60754c8f8400b0 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    428,
 /**/
     427,
 /**/