Patch 8.1.2244
Problem:    'wrapscan' is not used for "gn".
Solution:   Only reset 'wrapscan' for the first search round. (closes #5164)
Files:      src/search.c, src/testdir/test_gn.vim


*** ../vim-8.1.2243/src/search.c        2019-10-26 14:41:52.426302376 +0200
--- src/search.c        2019-11-02 23:11:03.860523451 +0100
***************
*** 4765,4773 ****
      pos_T     save_VIsual = VIsual;
      int               zero_width;
  
-     /* wrapping should not occur */
-     p_ws = FALSE;
- 
      /* Correct cursor when 'selection' is exclusive */
      if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor))
        dec_cursor();
--- 4765,4770 ----
***************
*** 4786,4795 ****
      zero_width = is_zero_width(spats[last_idx].pat, TRUE, &curwin->w_cursor,
                                                                      FORWARD);
      if (zero_width == -1)
-     {
-       p_ws = old_p_ws;
        return FAIL;  /* pattern not found */
-     }
  
      /*
       * The trick is to first search backwards and then search forward again,
--- 4783,4789 ----
***************
*** 4808,4818 ****
--- 4802,4818 ----
            flags = SEARCH_END;
        end_pos = pos;
  
+       // wrapping should not occur in the first round
+       if (i == 0)
+           p_ws = FALSE;
+ 
        result = searchit(curwin, curbuf, &pos, &end_pos,
                (dir ? FORWARD : BACKWARD),
                spats[last_idx].pat, (long) (i ? count : 1),
                SEARCH_KEEP | flags, RE_SEARCH, NULL);
  
+       p_ws = old_p_ws;
+ 
        /* First search may fail, but then start searching from the
         * beginning of the file (cursor might be on the search match)
         * except when Visual mode is active, so that extending the visual
***************
*** 4822,4828 ****
            curwin->w_cursor = orig_pos;
            if (VIsual_active)
                VIsual = save_VIsual;
-           p_ws = old_p_ws;
            return FAIL;
        }
        else if (i == 0 && !result)
--- 4822,4827 ----
***************
*** 4844,4850 ****
      }
  
      start_pos = pos;
-     p_ws = old_p_ws;
  
      if (!VIsual_active)
        VIsual = start_pos;
--- 4843,4848 ----
*** ../vim-8.1.2243/src/testdir/test_gn.vim     2019-10-26 14:41:52.426302376 
+0200
--- src/testdir/test_gn.vim     2019-11-02 23:17:21.294650269 +0100
***************
*** 135,142 ****
    call assert_equal(['ABCDEFGHi'], getline(1,'$'))
    call setline('.', ['abcdefghi'])
    let @/ = 'b'
    exe "norm! 0fhvhhgngU"
!   call assert_equal(['abcdefghi'], getline(1,'$'))
    sil! %d _
    call setline('.', ['abcdefghi'])
    let @/ = 'f'
--- 135,143 ----
    call assert_equal(['ABCDEFGHi'], getline(1,'$'))
    call setline('.', ['abcdefghi'])
    let @/ = 'b'
+   " this gn wraps around the end of the file
    exe "norm! 0fhvhhgngU"
!   call assert_equal(['aBCDEFGHi'], getline(1,'$'))
    sil! %d _
    call setline('.', ['abcdefghi'])
    let @/ = 'f'
*** ../vim-8.1.2243/src/version.c       2019-11-02 22:54:37.409188799 +0100
--- src/version.c       2019-11-02 23:22:05.305333861 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     2244,
  /**/

-- 
I have a drinking problem -- I can't afford it.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201911022223.xA2MN3WV032558%40masaka.moolenaar.net.

Raspunde prin e-mail lui