]> granicus.if.org Git - vim/commitdiff
patch 8.2.0999: moving to next sentence gets stuck on quote v8.2.0999
authorBram Moolenaar <Bram@vim.org>
Thu, 18 Jun 2020 13:33:25 +0000 (15:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 18 Jun 2020 13:33:25 +0000 (15:33 +0200)
Problem:    Moving to next sentence gets stuck on quote.
Solution:   When moving to the next sentence doesn't result in moving, advance
            a character and try again. (closes #6291)

src/testdir/test_textobjects.vim
src/textobject.c
src/version.c

index eed84e38531d8b977531d633ddfac83866285ac7..6eb6fbbf3ff8cbad46c3fe9bcc3727a0e5f156a2 100644 (file)
@@ -311,6 +311,17 @@ func Test_sentence_with_cursor_on_delimiter()
   normal! 17|yas
   call assert_equal("A '([sentence.])'  ", @")
 
+  " don't get stuck on a quote at the start of a sentence
+  %delete _
+  call setline(1, ['A sentence.', '"A sentence"?', 'A sentence!'])
+  normal gg))
+  call assert_equal(3, getcurpos()[1])
+
+  %delete _
+  call setline(1, ['A sentence.', "'A sentence'?", 'A sentence!'])
+  normal gg))
+  call assert_equal(3, getcurpos()[1])
+
   %delete _
 endfunc
 
index e876d528d759f3c89a8fb23a07243212517f10ac..23bdc966605c39a1e8cb3727ed8f3929586b127b 100644 (file)
@@ -26,6 +26,7 @@ static int skip_chars(int, int);
 findsent(int dir, long count)
 {
     pos_T      pos, tpos;
+    pos_T      prev_pos;
     int                c;
     int                (*func)(pos_T *);
     int                startlnum;
@@ -41,6 +42,8 @@ findsent(int dir, long count)
 
     while (count--)
     {
+       prev_pos = pos;
+
        /*
         * if on an empty line, skip up to a non-empty line
         */
@@ -133,6 +136,18 @@ found:
        while (!noskip && ((c = gchar_pos(&pos)) == ' ' || c == '\t'))
            if (incl(&pos) == -1)
                break;
+
+       if (EQUAL_POS(prev_pos, pos))
+       {
+           // didn't actually move, advance one character and try again
+           if ((*func)(&pos) == -1)
+           {
+               if (count)
+                   return FAIL;
+               break;
+           }
+           ++count;
+       }
     }
 
     setpcmark();
index 6ea3ce043c7bdfaf7b7d296544d00d46f25c95dc..f1cc22f5e5bda400f3e2b3661bc1b2a499a2bc65 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    999,
 /**/
     998,
 /**/