Mercurial > vim
diff src/ex_getln.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 | 050f5eaa9e50 |
children | d64f403289db |
line wrap: on
line diff
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -184,7 +184,7 @@ set_search_match(pos_T *t) * May change the last search pattern. */ static int -do_incsearch_highlighting(int firstc, incsearch_state_T *is_state, +do_incsearch_highlighting(int firstc, int *search_delim, incsearch_state_T *is_state, int *skiplen, int *patlen) { char_u *cmd; @@ -210,7 +210,10 @@ do_incsearch_highlighting(int firstc, in search_last_line = MAXLNUM; if (firstc == '/' || firstc == '?') + { + *search_delim = firstc; return TRUE; + } if (firstc != ':') return FALSE; @@ -273,6 +276,7 @@ do_incsearch_highlighting(int firstc, in p = skipwhite(p); delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; + *search_delim = delim; end = skip_regexp(p, delim, p_magic, NULL); use_last_pat = end == p && *end == delim; @@ -385,12 +389,13 @@ may_do_incsearch_highlighting( int next_char; int use_last_pat; int did_do_incsearch = is_state->did_incsearch; + int search_delim; // Parsing range may already set the last search pattern. // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); - if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) + if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) { restore_last_search_pattern(); finish_incsearch_highlighting(FALSE, is_state, TRUE); @@ -457,7 +462,7 @@ may_do_incsearch_highlighting( vim_memset(&sia, 0, sizeof(sia)); sia.sa_tm = &tm; #endif - found = do_search(NULL, firstc == ':' ? '/' : firstc, + found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim, ccline.cmdbuff + skiplen, count, search_flags, #ifdef FEAT_RELTIME &sia @@ -565,12 +570,13 @@ may_adjust_incsearch_highlighting( int search_flags = SEARCH_NOOF; int i; int save; + int search_delim; // Parsing range may already set the last search pattern. // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); - if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) + if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) { restore_last_search_pattern(); return OK; @@ -581,7 +587,7 @@ may_adjust_incsearch_highlighting( return FAIL; } - if (firstc == ccline.cmdbuff[skiplen]) + if (search_delim == ccline.cmdbuff[skiplen]) { pat = last_search_pattern(); skiplen = 0; @@ -668,13 +674,13 @@ may_adjust_incsearch_highlighting( static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state) { - int skiplen, patlen; + int skiplen, patlen, search_delim; // Parsing range may already set the last search pattern. // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); - if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) + if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) { restore_last_search_pattern(); return FAIL; @@ -693,7 +699,7 @@ may_add_char_to_search(int firstc, int * // the character to lowercase. if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff + skiplen)) *c = MB_TOLOWER(*c); - if (*c == firstc || vim_strchr((char_u *)( + if (*c == search_delim || vim_strchr((char_u *)( p_magic ? "\\~^$.*[" : "\\^$"), *c) != NULL) { // put a backslash before special characters