]> granicus.if.org Git - vim/commitdiff
patch 8.0.1417: test doesn't search for a sentence v8.0.1417
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Dec 2017 21:25:40 +0000 (22:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Dec 2017 21:25:40 +0000 (22:25 +0100)
Problem:    Test doesn't search for a sentence. Still fails when searching for
            start of sentence. (Dominique Pelle)
Solution:   Add paren. Check for MAXCOL in dec().

src/misc2.c
src/testdir/test_search.vim
src/version.c

index fd432cdba3e05e4a4825d6b5a4b5b2e8a44e751f..460ea74895b6f90edb3f10c7711bf91ffee4a038 100644 (file)
@@ -417,8 +417,21 @@ dec(pos_T *lp)
 #ifdef FEAT_VIRTUALEDIT
     lp->coladd = 0;
 #endif
-    if (lp->col > 0)           /* still within line */
+    if (lp->col == MAXCOL)
     {
+       /* past end of line */
+       p = ml_get(lp->lnum);
+       lp->col = (colnr_T)STRLEN(p);
+#ifdef FEAT_MBYTE
+       if (has_mbyte)
+           lp->col -= (*mb_head_off)(p, p + lp->col);
+#endif
+       return 0;
+    }
+
+    if (lp->col > 0)
+    {
+       /* still within line */
        lp->col--;
 #ifdef FEAT_MBYTE
        if (has_mbyte)
@@ -429,8 +442,10 @@ dec(pos_T *lp)
 #endif
        return 0;
     }
-    if (lp->lnum > 1)          /* there is a prior line */
+
+    if (lp->lnum > 1)
     {
+       /* there is a prior line */
        lp->lnum--;
        p = ml_get(lp->lnum);
        lp->col = (colnr_T)STRLEN(p);
@@ -440,7 +455,9 @@ dec(pos_T *lp)
 #endif
        return 1;
     }
-    return -1;                 /* at start of file */
+
+    /* at start of file */
+    return -1;
 }
 
 /*
index 84edfbbd4c719d5829c5ca3881fc7a89d82eef5f..9b96b49fdefbea7745845de6cb13d00f3803f09b 100644 (file)
@@ -733,6 +733,8 @@ endfunc
 func Test_search_sentence()
   new
   " this used to cause a crash
-  call assert_fails("/\\%'", 'E486')
+  call assert_fails("/\\%')", 'E486')
   call assert_fails("/", 'E486')
+  /\%'(
+  /
 endfunc
index 11ff6038eed155287106160aae9df0e80da9da0c..2ab6aac0f114c0669f1efe131d736180d49806ef 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1417,
 /**/
     1416,
 /**/