diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-06 20:03:58 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-06 20:03:58 +0100 |
commit | 6e450a57541676036203a72d40b2e604e938371e (patch) | |
tree | 4395ea731b069008270ed86e20cc3d0e3c8c983e | |
parent | 287266527abc163e191a06dd70518bbbdab4468f (diff) | |
download | vim-git-6e450a57541676036203a72d40b2e604e938371e.tar.gz |
patch 8.0.0147: searchpair() fails when 'magic' is offv8.0.0147
Problem: searchpair() does not work when 'magic' is off. (Chris Paul)
Solution: Add \m in the pattern. (Christian Brabandt, closes #1341)
-rw-r--r-- | src/evalfunc.c | 8 | ||||
-rw-r--r-- | src/testdir/test_search.vim | 15 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index f1fa7401e..10f6b182e 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -9509,15 +9509,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 3b9aff4e7..040a8098a 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 + diff --git a/src/version.c b/src/version.c index 775f7df21..bd0220ff6 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 147, +/**/ 146, /**/ 145, |