mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Problem: Vim9: Cannot use :silent with :endwhile. Solution: Allow for using the :silent modifier. (closes #8737)
This commit is contained in:
parent
b6f55bb5b4
commit
917c46abe5
@ -3061,9 +3061,11 @@ parse_command_modifiers(
|
|||||||
* Return TRUE if "cmod" has anything set.
|
* Return TRUE if "cmod" has anything set.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
has_cmdmod(cmdmod_T *cmod)
|
has_cmdmod(cmdmod_T *cmod, int ignore_silent)
|
||||||
{
|
{
|
||||||
return cmod->cmod_flags != 0
|
return (cmod->cmod_flags != 0 && (!ignore_silent
|
||||||
|
|| (cmod->cmod_flags
|
||||||
|
& ~(CMOD_SILENT | CMOD_ERRSILENT | CMOD_UNSILENT)) != 0))
|
||||||
|| cmod->cmod_split != 0
|
|| cmod->cmod_split != 0
|
||||||
|| cmod->cmod_verbose != 0
|
|| cmod->cmod_verbose != 0
|
||||||
|| cmod->cmod_tab != 0
|
|| cmod->cmod_tab != 0
|
||||||
@ -3074,9 +3076,9 @@ has_cmdmod(cmdmod_T *cmod)
|
|||||||
* If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
|
* If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cmdmod_error(void)
|
cmdmod_error(int ignore_silent)
|
||||||
{
|
{
|
||||||
if (in_vim9script() && has_cmdmod(&cmdmod))
|
if (in_vim9script() && has_cmdmod(&cmdmod, ignore_silent))
|
||||||
{
|
{
|
||||||
emsg(_(e_misplaced_command_modifier));
|
emsg(_(e_misplaced_command_modifier));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1026,7 +1026,7 @@ ex_endif(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
cstack_T *cstack = eap->cstack;
|
cstack_T *cstack = eap->cstack;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(FALSE))
|
||||||
return;
|
return;
|
||||||
did_endif = TRUE;
|
did_endif = TRUE;
|
||||||
if (cstack->cs_idx < 0
|
if (cstack->cs_idx < 0
|
||||||
@ -1355,7 +1355,7 @@ ex_endwhile(exarg_T *eap)
|
|||||||
int csf;
|
int csf;
|
||||||
int fl;
|
int fl;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(TRUE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_endwhile)
|
if (eap->cmdidx == CMD_endwhile)
|
||||||
@ -1593,7 +1593,7 @@ ex_try(exarg_T *eap)
|
|||||||
int skip;
|
int skip;
|
||||||
cstack_T *cstack = eap->cstack;
|
cstack_T *cstack = eap->cstack;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(FALSE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cstack->cs_idx == CSTACK_LEN - 1)
|
if (cstack->cs_idx == CSTACK_LEN - 1)
|
||||||
@ -1674,7 +1674,7 @@ ex_catch(exarg_T *eap)
|
|||||||
cstack_T *cstack = eap->cstack;
|
cstack_T *cstack = eap->cstack;
|
||||||
char_u *pat;
|
char_u *pat;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(FALSE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
||||||
@ -1839,7 +1839,7 @@ ex_finally(exarg_T *eap)
|
|||||||
int pending = CSTP_NONE;
|
int pending = CSTP_NONE;
|
||||||
cstack_T *cstack = eap->cstack;
|
cstack_T *cstack = eap->cstack;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(FALSE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
||||||
@ -1971,7 +1971,7 @@ ex_endtry(exarg_T *eap)
|
|||||||
void *rettv = NULL;
|
void *rettv = NULL;
|
||||||
cstack_T *cstack = eap->cstack;
|
cstack_T *cstack = eap->cstack;
|
||||||
|
|
||||||
if (cmdmod_error())
|
if (cmdmod_error(FALSE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
|
||||||
|
@ -10,8 +10,8 @@ char *ex_errmsg(char *msg, char_u *arg);
|
|||||||
int checkforcmd(char_u **pp, char *cmd, int len);
|
int checkforcmd(char_u **pp, char *cmd, int len);
|
||||||
int checkforcmd_noparen(char_u **pp, char *cmd, int len);
|
int checkforcmd_noparen(char_u **pp, char *cmd, int len);
|
||||||
int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, int skip_only);
|
int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, int skip_only);
|
||||||
int has_cmdmod(cmdmod_T *cmod);
|
int has_cmdmod(cmdmod_T *cmod, int ignore_silent);
|
||||||
int cmdmod_error(void);
|
int cmdmod_error(int ignore_silent);
|
||||||
void apply_cmdmod(cmdmod_T *cmod);
|
void apply_cmdmod(cmdmod_T *cmod);
|
||||||
void undo_cmdmod(cmdmod_T *cmod);
|
void undo_cmdmod(cmdmod_T *cmod);
|
||||||
int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);
|
int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);
|
||||||
@ -32,7 +32,7 @@ int ends_excmd(int c);
|
|||||||
int ends_excmd2(char_u *cmd_start, char_u *cmd);
|
int ends_excmd2(char_u *cmd_start, char_u *cmd);
|
||||||
char_u *find_nextcmd(char_u *p);
|
char_u *find_nextcmd(char_u *p);
|
||||||
char_u *check_nextcmd(char_u *p);
|
char_u *check_nextcmd(char_u *p);
|
||||||
void set_nextcmd(exarg_T *eap, char_u *p);
|
void set_nextcmd(exarg_T *eap, char_u *arg);
|
||||||
char_u *get_command_name(expand_T *xp, int idx);
|
char_u *get_command_name(expand_T *xp, int idx);
|
||||||
void not_exiting(void);
|
void not_exiting(void);
|
||||||
int before_quit_autocmds(win_T *wp, int quit_all, int forceit);
|
int before_quit_autocmds(win_T *wp, int quit_all, int forceit);
|
||||||
|
@ -807,6 +807,17 @@ def Test_modifier_silent_unsilent()
|
|||||||
echomsg "caught"
|
echomsg "caught"
|
||||||
endtry
|
endtry
|
||||||
assert_equal("\ncaught", execute(':1messages'))
|
assert_equal("\ncaught", execute(':1messages'))
|
||||||
|
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
set history=11
|
||||||
|
silent! while 0
|
||||||
|
set history=22
|
||||||
|
silent! endwhile
|
||||||
|
assert_equal(11, &history)
|
||||||
|
set history&
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_range_after_command_modifier()
|
def Test_range_after_command_modifier()
|
||||||
@ -836,13 +847,16 @@ def Test_useless_command_modifier()
|
|||||||
for i in [0]
|
for i in [0]
|
||||||
silent endfor
|
silent endfor
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
CheckDefFailure(lines, 'E1176:', 2)
|
||||||
|
CheckScriptSuccess(['vim9script'] + lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
while g:maybe
|
while g:maybe
|
||||||
silent endwhile
|
silent endwhile
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
CheckDefFailure(lines, 'E1176:', 2)
|
||||||
|
g:maybe = false
|
||||||
|
CheckScriptSuccess(['vim9script'] + lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
silent try
|
silent try
|
||||||
|
@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3324,
|
||||||
/**/
|
/**/
|
||||||
3323,
|
3323,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2344,7 +2344,7 @@ generate_cmdmods(cctx_T *cctx, cmdmod_T *cmod)
|
|||||||
{
|
{
|
||||||
isn_T *isn;
|
isn_T *isn;
|
||||||
|
|
||||||
if (has_cmdmod(cmod))
|
if (has_cmdmod(cmod, FALSE))
|
||||||
{
|
{
|
||||||
cctx->ctx_has_cmdmod = TRUE;
|
cctx->ctx_has_cmdmod = TRUE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user