patch 9.2.0729: % skips parens on continued quoted lines
Commit:
https://github.com/vim/vim/commit/c44a6561cc886d1518f02ca7dffdae270e2aec00
Author: Barrett Ruth <
b...@barrettruth.com>
Date: Fri Jun 26 19:46:11 2026 +0000
patch 9.2.0729: % skips parens on continued quoted lines
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 <
b...@barrettruth.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/search.c b/src/search.c
index 77f945ddf..7db964f22 100644
--- a/src/search.c
+++ b/src/search.c
@@ -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;
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index c4178fdec..be0a460b7 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -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
diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim
index 320cd169b..a336dc0cf 100644
--- a/src/testdir/test_textobjects.vim
+++ b/src/testdir/test_textobjects.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 7673cd979..3ebb3b8d2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 729,
/**/
728,
/**/