mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 07:18:17 +00:00
vim-patch:8.0.0147 #7121
Problem: searchpair() does not work when 'magic' is off. (Chris Paul)
Solution: Add \m in the pattern. (Christian Brabandt, closes vim/vim#1341)
6e450a5754
This commit is contained in:
@@ -14203,6 +14203,8 @@ do_searchpair (
|
|||||||
int nest = 1;
|
int nest = 1;
|
||||||
int options = SEARCH_KEEP;
|
int options = SEARCH_KEEP;
|
||||||
proftime_T tm;
|
proftime_T tm;
|
||||||
|
size_t pat2_len;
|
||||||
|
size_t pat3_len;
|
||||||
|
|
||||||
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
|
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
@@ -14211,18 +14213,22 @@ do_searchpair (
|
|||||||
/* Set the time limit, if there is one. */
|
/* Set the time limit, if there is one. */
|
||||||
tm = profile_setlimit(time_limit);
|
tm = profile_setlimit(time_limit);
|
||||||
|
|
||||||
/* Make two search patterns: start/end (pat2, for in nested pairs) and
|
// Make two search patterns: start/end (pat2, for in nested pairs) and
|
||||||
* start/middle/end (pat3, for the top pair). */
|
// start/middle/end (pat3, for the top pair).
|
||||||
pat2 = xmalloc(STRLEN(spat) + STRLEN(epat) + 15);
|
pat2_len = STRLEN(spat) + STRLEN(epat) + 17;
|
||||||
pat3 = xmalloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 23);
|
pat2 = xmalloc(pat2_len);
|
||||||
sprintf((char *)pat2, "\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
|
pat3_len = STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25;
|
||||||
if (*mpat == NUL)
|
pat3 = xmalloc(pat3_len);
|
||||||
|
snprintf((char *)pat2, pat2_len, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
|
||||||
|
if (*mpat == NUL) {
|
||||||
STRCPY(pat3, pat2);
|
STRCPY(pat3, pat2);
|
||||||
else
|
} else {
|
||||||
sprintf((char *)pat3, "\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)",
|
snprintf((char *)pat3, pat3_len,
|
||||||
spat, epat, mpat);
|
"\\m\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat, mpat);
|
||||||
if (flags & SP_START)
|
}
|
||||||
|
if (flags & SP_START) {
|
||||||
options |= SEARCH_START;
|
options |= SEARCH_START;
|
||||||
|
}
|
||||||
|
|
||||||
save_cursor = curwin->w_cursor;
|
save_cursor = curwin->w_cursor;
|
||||||
pos = curwin->w_cursor;
|
pos = curwin->w_cursor;
|
||||||
|
@@ -283,3 +283,18 @@ func Test_use_sub_pat()
|
|||||||
call X()
|
call X()
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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
|
||||||
|
|
||||||
|
@@ -805,7 +805,7 @@ static const int included_patches[] = {
|
|||||||
150,
|
150,
|
||||||
// 149,
|
// 149,
|
||||||
// 148,
|
// 148,
|
||||||
// 147,
|
147,
|
||||||
146,
|
146,
|
||||||
// 145 NA
|
// 145 NA
|
||||||
// 144 NA
|
// 144 NA
|
||||||
|
Reference in New Issue
Block a user