]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0729: % skips parens on continued quoted lines v9.2.0729
authorBarrett Ruth <br@barrettruth.com>
Fri, 26 Jun 2026 19:46:11 +0000 (19:46 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 26 Jun 2026 19:46:11 +0000 (19:46 +0000)
Problem:  The "%" command and bracket/text-object motions can skip the
          matching paren or bracket on a line with quotes and a trailing
          backslash.
Solution: Use the quote state at the search start when an odd-quote line
          is continued with a backslash, instead of always treating the
          search as starting in quotes (Barrett Ruth).

closes: #20631

Signed-off-by: Barrett Ruth <br@barrettruth.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/search.c
src/testdir/test_search.vim
src/testdir/test_textobjects.vim
src/version.c

index 77f945ddf823c9f99ededc063e42fdfdc5f626a8..7db964f22bf622a3fcdb0c347ef98d236e48f5c4 100644 (file)
@@ -2664,9 +2664,9 @@ findmatchlimit(
                    do_quotes = 1;
                    if (start_in_quotes == MAYBE)
                    {
-                       // Do we need to use at_start here?
-                       inquote = TRUE;
-                       start_in_quotes = TRUE;
+                       inquote = at_start;
+                       if (inquote)
+                           start_in_quotes = TRUE;
                    }
                    else if (backwards)
                        inquote = TRUE;
index c4178fdece7ed5ef6a279df08131a36dfd555529..be0a460b71e08736c1f0b5c00edea3f1b7e4d2b8 100644 (file)
@@ -2166,6 +2166,19 @@ func Test_search_match_paren()
   normal [(
   call assert_equal([1, 4], [line('.'), col('.')])
 
+  call setline(1, ['x" (a "b" )\', '")'])
+  call cursor(1, 4)
+  normal %
+  call assert_equal([1, 11], [line('.'), col('.')])
+  normal %
+  call assert_equal([1, 4], [line('.'), col('.')])
+  call cursor(1, 10)
+  normal [(
+  call assert_equal([1, 4], [line('.'), col('.')])
+  call cursor(1, 4)
+  normal ])
+  call assert_equal([1, 11], [line('.'), col('.')])
+
   " matching parenthesis in 'virtualedit' mode with cursor after the eol
   call setline(1, 'abc(defgh)')
   set virtualedit=all
index 320cd169b639f77ea32d0b8e90a2aeddec901c45..a336dc0cf8c3399087443c6ce4db116798141b0e 100644 (file)
@@ -648,6 +648,16 @@ func Test_textobj_find_paren_forward()
   normal 0di)
   call assert_equal('foo ()', getline(1))
 
+  call setline(1, ['x" (a "b" )\', '")'])
+  call cursor(1, 6)
+  normal va)y
+  call assert_equal('(a "b" )', @")
+
+  call setline(1, ['x" [a "b" ]\', '"]'])
+  call cursor(1, 6)
+  normal va]y
+  call assert_equal('[a "b" ]', @")
+
   bw!
 endfunc
 
index 7673cd97984131058b3713100b7013547d0f4fcb..3ebb3b8d2e342361864698ff7411444d20355293 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    729,
 /**/
     728,
 /**/