From e86190e7c1297da29d0fc2415fdeca5ecae8d2ba Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Fri, 23 Dec 2022 19:06:04 +0000 Subject: patch 9.0.1092: search error message doesn't show used pattern Problem: Search error message doesn't show used pattern. Solution: Pass the actually used pattern to where the error message is given. (Rob Pilling, closes #11742) --- src/ex_cmds.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/ex_cmds.c') diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 5b398089fd..693b0acace 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1902,12 +1902,12 @@ check_writable(char_u *fname) #endif /* - * write current buffer to file 'eap->arg' - * if 'eap->append' is TRUE, append to the file + * Write the current buffer to file "eap->arg". + * If "eap->append" is TRUE, append to the file. * - * if *eap->arg == NUL write to current file + * If "*eap->arg == NUL" write to current file. * - * return FAIL for failure, OK otherwise + * Return FAIL for failure, OK otherwise. */ int do_write(exarg_T *eap) @@ -4011,7 +4011,7 @@ ex_substitute(exarg_T *eap) return; } - if (search_regcomp(pat, RE_SUBST, which_pat, SEARCH_HIS, ®match) == FAIL) + if (search_regcomp(pat, NULL, RE_SUBST, which_pat, SEARCH_HIS, ®match) == FAIL) { if (subflags.do_error) emsg(_(e_invalid_command)); @@ -5039,6 +5039,7 @@ ex_global(exarg_T *eap) char_u delim; // delimiter, normally '/' char_u *pat; + char_u *used_pat; regmmatch_T regmatch; int match; int which_pat; @@ -5104,7 +5105,7 @@ ex_global(exarg_T *eap) *cmd++ = NUL; // replace it with a NUL } - if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) + if (search_regcomp(pat, &used_pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) { emsg(_(e_invalid_command)); return; @@ -5148,16 +5149,16 @@ ex_global(exarg_T *eap) if (type == 'v') { if (in_vim9script()) - semsg(_(e_pattern_found_in_every_line_str), pat); + semsg(_(e_pattern_found_in_every_line_str), used_pat); else - smsg(_("Pattern found in every line: %s"), pat); + smsg(_("Pattern found in every line: %s"), used_pat); } else { if (in_vim9script()) - semsg(_(e_pattern_not_found_str), pat); + semsg(_(e_pattern_not_found_str), used_pat); else - smsg(_("Pattern not found: %s"), pat); + smsg(_("Pattern not found: %s"), used_pat); } } else -- cgit v1.2.3