]> granicus.if.org Git - vim/commitdiff
patch 8.2.1823: "gN" does not select the matched string v8.2.1823
authorBram Moolenaar <Bram@vim.org>
Sat, 10 Oct 2020 14:45:25 +0000 (16:45 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 10 Oct 2020 14:45:25 +0000 (16:45 +0200)
Problem:    "gN" does not select the matched string.
Solution:   Move the cursor to the start of the match.

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

index fd668383b74d6f998267c73bbe9cc7861007639b..45e4f9c1abe4c32d4cc7dc24a8ba660f832869bc 100644 (file)
@@ -3047,7 +3047,7 @@ current_search(
     curwin->w_cursor = end_pos;
     if (LT_POS(VIsual, end_pos) && forward)
        dec_cursor();
-    else if (VIsual_active && LT_POS(curwin->w_cursor, VIsual))
+    else if (VIsual_active && LT_POS(curwin->w_cursor, VIsual) && forward)
        curwin->w_cursor = pos;   // put the cursor on the start of the match
     VIsual_active = TRUE;
     VIsual_mode = 'v';
index b90aa5f1d617533850753d99f6f847141c7390d5..a2a7ac3f0f6b3f008a2e5fff1843fa9c79357601 100644 (file)
@@ -172,7 +172,16 @@ func Test_gn_command()
   normal 0wgNy
   call assert_equal('one', @")
   set selection&
-endfu
+endfunc
+
+func Test_gN_repeat()
+  new
+  call setline(1, 'this list is a list with a list of a list.')
+  /list
+  normal $gNgNgNx
+  call assert_equal('list with a list of a list', @")
+  bwipe!
+endfunc
 
 func Test_gn_multi_line()
   new
index e0bcc90129bf923d8e2292cc31d191c00a689237..e30c02dd1552f4192e83778123cd2d5b3959aea7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1823,
 /**/
     1822,
 /**/