diff src/search.c @ 19475:5512aa74cb62 v8.2.0295

patch 8.2.0295: highlighting for :s wrong when using different separator Commit: https://github.com/vim/vim/commit/c036e87bd7001238ab7cc5d9e30e59bbf989a5fd Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 21 21:30:52 2020 +0100 patch 8.2.0295: highlighting for :s wrong when using different separator Problem: Highlighting for :s wrong when using different separator. Solution: Use separat argument for search direction and separator. (Rob Pilling, closes #5665)
author Bram Moolenaar <Bram@vim.org>
date Fri, 21 Feb 2020 21:45:04 +0100
parents 6c944fee0d7e
children 5feb426d2ea1
line wrap: on
line diff
--- 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;