mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.4506: "pattern not found" for :global is not an error message
Problem: "pattern not found" for :global is not an error message. Solution: In Vim9 script make this an actual error, so that try/catch can be used as expected.
This commit is contained in:
@@ -1346,7 +1346,8 @@ EXTERN char e_comma_required[]
|
|||||||
EXTERN char e_commentstring_must_be_empty_or_contain_str[]
|
EXTERN char e_commentstring_must_be_empty_or_contain_str[]
|
||||||
INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
|
INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
|
||||||
#endif
|
#endif
|
||||||
// E538 unused
|
EXTERN char e_pattern_found_in_every_line_str[]
|
||||||
|
INIT(= N_("E538: Pattern found in every line: %s"));
|
||||||
EXTERN char e_illegal_character_str[]
|
EXTERN char e_illegal_character_str[]
|
||||||
INIT(= N_("E539: Illegal character <%s>"));
|
INIT(= N_("E539: Illegal character <%s>"));
|
||||||
#ifdef FEAT_STL_OPT
|
#ifdef FEAT_STL_OPT
|
||||||
|
@@ -5001,9 +5001,19 @@ ex_global(exarg_T *eap)
|
|||||||
else if (ndone == 0)
|
else if (ndone == 0)
|
||||||
{
|
{
|
||||||
if (type == 'v')
|
if (type == 'v')
|
||||||
smsg(_("Pattern found in every line: %s"), pat);
|
{
|
||||||
|
if (in_vim9script())
|
||||||
|
semsg(_(e_pattern_found_in_every_line_str), pat);
|
||||||
|
else
|
||||||
|
smsg(_("Pattern found in every line: %s"), pat);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
smsg(_("Pattern not found: %s"), pat);
|
{
|
||||||
|
if (in_vim9script())
|
||||||
|
semsg(_(e_pattern_not_found_str), pat);
|
||||||
|
else
|
||||||
|
smsg(_("Pattern not found: %s"), pat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -68,6 +68,26 @@ func Test_global_print()
|
|||||||
v/foo\|bar/p
|
v/foo\|bar/p
|
||||||
call assert_notequal('', v:statusmsg)
|
call assert_notequal('', v:statusmsg)
|
||||||
|
|
||||||
|
" In Vim9 script this is an error
|
||||||
|
let caught = 'no'
|
||||||
|
try
|
||||||
|
vim9cmd v/foo\|bar/p
|
||||||
|
catch /E538/
|
||||||
|
let caught = 'yes'
|
||||||
|
call assert_match('E538: Pattern found in every line: foo\|bar', v:exception)
|
||||||
|
endtry
|
||||||
|
call assert_equal('yes', caught)
|
||||||
|
|
||||||
|
" In Vim9 script not matching is an error
|
||||||
|
let caught = 'no'
|
||||||
|
try
|
||||||
|
vim9cmd g/foobarnotfound/p
|
||||||
|
catch /E486/
|
||||||
|
let caught = 'yes'
|
||||||
|
call assert_match('E486: Pattern not found: foobarnotfound', v:exception)
|
||||||
|
endtry
|
||||||
|
call assert_equal('yes', caught)
|
||||||
|
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4506,
|
||||||
/**/
|
/**/
|
||||||
4505,
|
4505,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user