]> granicus.if.org Git - vim/commitdiff
patch 8.1.2218: "gN" is off by one in Visual mode v8.1.2218
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Oct 2019 12:42:09 +0000 (14:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Oct 2019 12:42:09 +0000 (14:42 +0200)
Problem:    "gN" is off by one in Visual mode.
Solution:   Check moving forward. (Christian Brabandt, #5075)

src/search.c
src/testdir/test_gn.vim
src/version.c

index a1f8998df77d10dd907a53a3a10c4225e88289e1..18f7905e585abe1dd2f830af41e1485c0df14f48 100644 (file)
@@ -4677,7 +4677,7 @@ abort_search:
 #endif /* FEAT_TEXTOBJ */
 
 /*
- * Check if the pattern is one character long or zero-width.
+ * Check if the pattern is zero-width.
  * If move is TRUE, check from the beginning of the buffer, else from position
  * "cur".
  * "direction" is FORWARD or BACKWARD.
@@ -4851,7 +4851,7 @@ current_search(
 
     // put cursor on last character of match
     curwin->w_cursor = end_pos;
-    if (LT_POS(VIsual, end_pos))
+    if (LT_POS(VIsual, end_pos) && forward)
        dec_cursor();
     else if (VIsual_active && LT_POS(curwin->w_cursor, VIsual))
        curwin->w_cursor = pos;   // put the cursor on the start of the match
index ecf9b82899da56babc5f2a7189ac6910469feea2..9edf0a21eaef740ea7fbc85020a313f441eddec6 100644 (file)
@@ -148,6 +148,11 @@ func Test_gn_command()
   norm! gg0f7vhhhhgnd
   call assert_equal(['12348'], getline(1,'$'))
   sil! %d _
+  call setline('.', ['12345678'])
+  let @/ = '5'
+  norm! gg0f2vf7gNd
+  call assert_equal(['1678'], getline(1,'$'))
+  sil! %d _
 
   set wrapscan&vim
 endfu
index 71d8959741bd6bcb0304f0bbdfa5b1cba345d170..af2930252227b880ad027d795ecb4725873009a0 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2218,
 /**/
     2217,
 /**/