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 -- b...@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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230122201502.C05571C0548%40moolenaar.net.

Reply via email to