From b86381f425223adf0ff91fa0746914a5774ddabb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 21 May 2024 06:22:23 +0800 Subject: vim-patch:9.1.0426: too many strlen() calls in search.c Problem: too many strlen() calls in search.c Solution: refactor code and remove more strlen() calls, use explicit variable to remember strlen (John Marriott) closes: vim/vim#14796 https://github.com/vim/vim/commit/8c85a2a49acf80e4f53ec51e6ff2a5f3830eeddb Co-authored-by: John Marriott --- test/unit/search_spec.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/unit/search_spec.lua b/test/unit/search_spec.lua index f68cd88c12..9171cf9f06 100644 --- a/test/unit/search_spec.lua +++ b/test/unit/search_spec.lua @@ -35,9 +35,10 @@ itp('pat_has_uppercase', function() end) describe('search_regcomp', function() - local search_regcomp = function(pat, pat_save, pat_use, options) + local search_regcomp = function(pat, patlen, pat_save, pat_use, options) local regmatch = ffi.new('regmmatch_T') - local fail = search.search_regcomp(to_cstr(pat), nil, pat_save, pat_use, options, regmatch) + local fail = + search.search_regcomp(to_cstr(pat), patlen, nil, pat_save, pat_use, options, regmatch) return fail, regmatch end @@ -50,7 +51,7 @@ describe('search_regcomp', function() globals.curwin.w_onebuf_opt.wo_rl = 1 globals.curwin.w_onebuf_opt.wo_rlc = to_cstr('s') globals.cmdmod.cmod_flags = globals.CMOD_KEEPPATTERNS - local fail = search_regcomp('a\192', 0, 0, 0) + local fail = search_regcomp('a\192', 2, 0, 0, 0) eq(1, fail) eq('\192a', get_search_pat()) end) -- cgit From 59fe8ffdeaacc08b811aa97d270daec6d6ed2769 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 22 May 2024 05:35:21 +0800 Subject: 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. --- test/old/testdir/test_tagjump.vim | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'test') 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('