From: Barrett Ruth
Date: Fri, 26 Jun 2026 19:46:11 +0000 (+0000)
Subject: patch 9.2.0729: % skips parens on continued quoted lines
X-Git-Tag: v9.2.0729^0
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c44a6561cc886d1518f02ca7dffdae270e2aec00;p=thirdparty%2Fvim.git
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
Signed-off-by: Christian Brabandt
---
diff --git a/src/search.c b/src/search.c
index 77f945ddf8..7db964f22b 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 c4178fdece..be0a460b71 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 320cd169b6..a336dc0cf8 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 7673cd9798..3ebb3b8d2e 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,
/**/