summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-21 21:30:52 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-21 21:30:52 +0100
commitc036e87bd7001238ab7cc5d9e30e59bbf989a5fd (patch)
tree2ed9e85172f565706463cee71e7ad6a93637297a /src/search.c
parent5b1c8fe3d588ab450d4646a0088db4efda88200a (diff)
downloadvim-git-c036e87bd7001238ab7cc5d9e30e59bbf989a5fd.tar.gz
patch 8.2.0295: highlighting for :s wrong when using different separatorv8.2.0295
Problem: Highlighting for :s wrong when using different separator. Solution: Use separat argument for search direction and separator. (Rob Pilling, closes #5665)
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/search.c b/src/search.c
index 3b310dc2a..2005b7901 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1187,6 +1187,7 @@ first_submatch(regmmatch_T *rp)
do_search(
oparg_T *oap, // can be NULL
int dirc, // '/' or '?'
+ int search_delim, // the delimiter for the search, e.g. '%' in s%regex%replacement%
char_u *pat,
long count,
int options,
@@ -1285,7 +1286,7 @@ do_search(
searchstr = pat;
dircp = NULL;
// use previous pattern
- if (pat == NULL || *pat == NUL || *pat == dirc)
+ if (pat == NULL || *pat == NUL || *pat == search_delim)
{
if (spats[RE_SEARCH].pat == NULL) // no previous pattern
{
@@ -1311,7 +1312,7 @@ do_search(
* If there is a matching '/' or '?', toss it.
*/
ps = strcopy;
- p = skip_regexp(pat, dirc, (int)p_magic, &strcopy);
+ p = skip_regexp(pat, search_delim, (int)p_magic, &strcopy);
if (strcopy != ps)
{
// made a copy of "pat" to change "\?" to "?"
@@ -1319,7 +1320,7 @@ do_search(
pat = strcopy;
searchstr = strcopy;
}
- if (*p == dirc)
+ if (*p == search_delim)
{
dircp = p; // remember where we put the NUL
*p++ = NUL;
@@ -1525,7 +1526,7 @@ do_search(
RE_LAST, sia);
if (dircp != NULL)
- *dircp = dirc; // restore second '/' or '?' for normal_cmd()
+ *dircp = search_delim; // restore second '/' or '?' for normal_cmd()
if (!shortmess(SHM_SEARCH)
&& ((dirc == '/' && LT_POS(pos, curwin->w_cursor))
@@ -1606,6 +1607,7 @@ do_search(
break;
dirc = *++pat;
+ search_delim = dirc;
if (dirc != '?' && dirc != '/')
{
retval = 0;