To: vim_dev@googlegroups.com Subject: Patch 9.0.1233 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1233 Problem: search() loops forever if "skip" is TRUE for all matches. Solution: Keep the position of the first match. Files: src/evalfunc.c, src/testdir/test_search.vim *** ../vim-9.0.1232/src/evalfunc.c 2023-01-18 15:27:35.128167521 +0000 --- src/evalfunc.c 2023-01-22 20:12:43.994465201 +0000 *************** *** 8794,8800 **** if (subpatnum == FAIL || !use_skip) // didn't find it or no skip argument break; ! firstpos = pos; // If the skip expression matches, ignore this match. { --- 8794,8801 ---- if (subpatnum == FAIL || !use_skip) // didn't find it or no skip argument break; ! if (firstpos.lnum == 0) ! firstpos = pos; // If the skip expression matches, ignore this match. { *** ../vim-9.0.1232/src/testdir/test_search.vim 2022-12-31 11:44:51.549772464 +0000 --- src/testdir/test_search.vim 2023-01-22 20:11:32.854473919 +0000 *************** *** 1411,1416 **** --- 1411,1432 ---- set noincsearch endfunc + func Test_search_skip_all_matches() + enew + call setline(1, ['no match here', + \ 'match this line', + \ 'nope', + \ 'match in this line', + \ 'last line', + \ ]) + call cursor(1, 1) + let lnum = search('this', '', 0, 0, 'getline(".") =~ "this line"') + " Only check that no match is found. Previously it searched forever. + call assert_equal(0, lnum) + + bwipe! + endfunc + func Test_search_undefined_behaviour() CheckFeature terminal *** ../vim-9.0.1232/src/version.c 2023-01-22 18:58:26.730874051 +0000 --- src/version.c 2023-01-22 19:10:18.251031103 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1233, /**/ -- Those who live by the sword get shot by those who don't. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///