Attached patch fixes it.
On Mi, 28 Dez 2016, Chris Paul wrote:
> `call searchpair('\[','',']','bW')` <- behaves differently with set nomagic
> contrary to the docs
>
> ```
> [
> " cursor here
> ]
> ```
Mit freundlichen Grüßen
Christian
--
Wer A sagt, wird auch Au sagen.
-- Zarko Petan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 65f9c96086aa99a39f6e20aa0dded80abed4d684 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Thu, 29 Dec 2016 21:42:00 +0100
Subject: [PATCH] Use magic value for searchpairpos like its documented
---
src/evalfunc.c | 8 ++++----
src/testdir/test_search.vim | 15 +++++++++++++++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 08be12b..28ae06e 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -9508,15 +9508,15 @@ do_searchpair(
/* Make two search patterns: start/end (pat2, for in nested pairs) and
* start/middle/end (pat3, for the top pair). */
- pat2 = alloc((unsigned)(STRLEN(spat) + STRLEN(epat) + 15));
- pat3 = alloc((unsigned)(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 23));
+ pat2 = alloc((unsigned)(STRLEN(spat) + STRLEN(epat) + 17));
+ pat3 = alloc((unsigned)(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25));
if (pat2 == NULL || pat3 == NULL)
goto theend;
- sprintf((char *)pat2, "\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
+ sprintf((char *)pat2, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
if (*mpat == NUL)
STRCPY(pat3, pat2);
else
- sprintf((char *)pat3, "\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)",
+ sprintf((char *)pat3, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)",
spat, epat, mpat);
if (flags & SP_START)
options |= SEARCH_START;
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 3b9aff4..040a809 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -279,3 +279,18 @@ func Test_use_sub_pat()
call X()
bwipe!
endfunc
+
+func Test_searchpair()
+ new
+ call setline(1, ['other code here', '', '[', '" cursor here', ']'])
+ 4
+ let a=searchpair('\[','',']','bW')
+ call assert_equal(3, a)
+ set nomagic
+ 4
+ let a=searchpair('\[','',']','bW')
+ call assert_equal(3, a)
+ set magic
+ q!
+endfunc
+
--
2.10.2