@@ -184,7 +184,7 @@ set_search_match(pos_T *t)
184184 * May change the last search pattern.
185185 */
186186 static int
187- do_incsearch_highlighting (int firstc , incsearch_state_T * is_state ,
187+ do_incsearch_highlighting (int firstc , int * search_delim , incsearch_state_T * is_state ,
188188 int * skiplen , int * patlen )
189189{
190190 char_u * cmd ;
@@ -210,7 +210,10 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
210210 search_last_line = MAXLNUM ;
211211
212212 if (firstc == '/' || firstc == '?' )
213+ {
214+ * search_delim = firstc ;
213215 return TRUE;
216+ }
214217 if (firstc != ':' )
215218 return FALSE;
216219
@@ -273,6 +276,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
273276
274277 p = skipwhite (p );
275278 delim = (delim_optional && vim_isIDc (* p )) ? ' ' : * p ++ ;
279+ * search_delim = delim ;
276280 end = skip_regexp (p , delim , p_magic , NULL );
277281
278282 use_last_pat = end == p && * end == delim ;
@@ -385,12 +389,13 @@ may_do_incsearch_highlighting(
385389 int next_char ;
386390 int use_last_pat ;
387391 int did_do_incsearch = is_state -> did_incsearch ;
392+ int search_delim ;
388393
389394 // Parsing range may already set the last search pattern.
390395 // NOTE: must call restore_last_search_pattern() before returning!
391396 save_last_search_pattern ();
392397
393- if (!do_incsearch_highlighting (firstc , is_state , & skiplen , & patlen ))
398+ if (!do_incsearch_highlighting (firstc , & search_delim , is_state , & skiplen , & patlen ))
394399 {
395400 restore_last_search_pattern ();
396401 finish_incsearch_highlighting (FALSE, is_state , TRUE);
@@ -457,7 +462,7 @@ may_do_incsearch_highlighting(
457462 vim_memset (& sia , 0 , sizeof (sia ));
458463 sia .sa_tm = & tm ;
459464#endif
460- found = do_search (NULL , firstc == ':' ? '/' : firstc ,
465+ found = do_search (NULL , firstc == ':' ? '/' : firstc , search_delim ,
461466 ccline .cmdbuff + skiplen , count , search_flags ,
462467#ifdef FEAT_RELTIME
463468 & sia
@@ -565,12 +570,13 @@ may_adjust_incsearch_highlighting(
565570 int search_flags = SEARCH_NOOF ;
566571 int i ;
567572 int save ;
573+ int search_delim ;
568574
569575 // Parsing range may already set the last search pattern.
570576 // NOTE: must call restore_last_search_pattern() before returning!
571577 save_last_search_pattern ();
572578
573- if (!do_incsearch_highlighting (firstc , is_state , & skiplen , & patlen ))
579+ if (!do_incsearch_highlighting (firstc , & search_delim , is_state , & skiplen , & patlen ))
574580 {
575581 restore_last_search_pattern ();
576582 return OK ;
@@ -581,7 +587,7 @@ may_adjust_incsearch_highlighting(
581587 return FAIL ;
582588 }
583589
584- if (firstc == ccline .cmdbuff [skiplen ])
590+ if (search_delim == ccline .cmdbuff [skiplen ])
585591 {
586592 pat = last_search_pattern ();
587593 skiplen = 0 ;
@@ -668,13 +674,13 @@ may_adjust_incsearch_highlighting(
668674 static int
669675may_add_char_to_search (int firstc , int * c , incsearch_state_T * is_state )
670676{
671- int skiplen , patlen ;
677+ int skiplen , patlen , search_delim ;
672678
673679 // Parsing range may already set the last search pattern.
674680 // NOTE: must call restore_last_search_pattern() before returning!
675681 save_last_search_pattern ();
676682
677- if (!do_incsearch_highlighting (firstc , is_state , & skiplen , & patlen ))
683+ if (!do_incsearch_highlighting (firstc , & search_delim , is_state , & skiplen , & patlen ))
678684 {
679685 restore_last_search_pattern ();
680686 return FAIL ;
@@ -693,7 +699,7 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
693699 // the character to lowercase.
694700 if (p_ic && p_scs && !pat_has_uppercase (ccline .cmdbuff + skiplen ))
695701 * c = MB_TOLOWER (* c );
696- if (* c == firstc || vim_strchr ((char_u * )(
702+ if (* c == search_delim || vim_strchr ((char_u * )(
697703 p_magic ? "\\~^$.*[" : "\\^$" ), * c ) != NULL )
698704 {
699705 // put a backslash before special characters
0 commit comments