]> granicus.if.org Git - vim/commitdiff
patch 8.0.0364: ]s does not move cursor with two spell errors in one line v8.0.0364
authorBram Moolenaar <Bram@vim.org>
Sat, 25 Feb 2017 13:21:10 +0000 (14:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 25 Feb 2017 13:21:10 +0000 (14:21 +0100)
Problem:    ]s does not move cursor with two spell errors in one line. (Manuel
            Ortega)
Solution:   Don't stop search immediately when wrapped, search the line first.
            (Ken Takata)  Add a test.

src/Makefile
src/spell.c
src/testdir/Make_all.mak
src/testdir/test_spell.vim [new file with mode: 0644]
src/version.c

index 227e1df4eb5e0596e47b12639e9c6c493822bf40..5ed83628b4d0a7dabc8c1793928f3a3b7a9c5b01 100644 (file)
@@ -2193,6 +2193,7 @@ test_arglist \
        test_smartindent \
        test_sort \
        test_source_utf8 \
+       test_spell \
        test_startup \
        test_startup_utf8 \
        test_stat \
index 91a48fa77e03d95c6442c3495163615906a98d76..f124ef21df443d949dacd38f51b5ed04a6dcd92d 100644 (file)
@@ -1734,14 +1734,14 @@ spell_move_to(
        if (curline)
            break;      /* only check cursor line */
 
+       /* If we are back at the starting line and searched it again there
+        * is no match, give up. */
+       if (lnum == wp->w_cursor.lnum && wrapped)
+           break;
+
        /* Advance to next line. */
        if (dir == BACKWARD)
        {
-           /* If we are back at the starting line and searched it again there
-            * is no match, give up. */
-           if (lnum == wp->w_cursor.lnum && wrapped)
-               break;
-
            if (lnum > 1)
                --lnum;
            else if (!p_ws)
@@ -1775,7 +1775,7 @@ spell_move_to(
 
            /* If we are back at the starting line and there is no match then
             * give up. */
-           if (lnum == wp->w_cursor.lnum && (!found_one || wrapped))
+           if (lnum == wp->w_cursor.lnum && !found_one)
                break;
 
            /* Skip the characters at the start of the next line that were
index 057e8b13aab4bf8d1d5a3eb3c97c97948bb2d509..18dfdc8e7478358a4b4fac72c8c2421529d054b0 100644 (file)
@@ -192,6 +192,7 @@ NEW_TESTS = test_arglist.res \
            test_search.res \
            test_signs.res \
            test_smartindent.res \
+           test_spell.res \
            test_startup.res \
            test_startup_utf8.res \
            test_stat.res \
diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim
new file mode 100644 (file)
index 0000000..e6c3729
--- /dev/null
@@ -0,0 +1,20 @@
+" Test spell checking
+" TODO: move test58 tests here
+
+if !has('spell')
+  finish
+endif
+
+func Test_wrap_search()
+  new
+  call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
+  set spell wrapscan
+  normal ]s
+  call assert_equal('plong', expand('<cword>'))
+  normal ]s
+  call assert_equal('zpelling', expand('<cword>'))
+  normal ]s
+  call assert_equal('plong', expand('<cword>'))
+  bwipe!
+  set nospell
+endfunc
index 6b2a9f17cbe083bced1badfab43667fbb8420741..ffacb9ae810f52b18667245872df440408691523 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    364,
 /**/
     363,
 /**/