mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3149: some plugins have a problem with the error check
Problem: Some plugins have a problem with the error check for using :command with -complete but without -nargs. Solution: In legacy script only give a warning message.
This commit is contained in:
@@ -3613,6 +3613,12 @@ verbose_open(void)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
give_warning(char_u *message, int hl)
|
give_warning(char_u *message, int hl)
|
||||||
|
{
|
||||||
|
give_warning_with_source(message, hl, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
give_warning_with_source(char_u *message, int hl, int with_source)
|
||||||
{
|
{
|
||||||
// Don't do this for ":silent".
|
// Don't do this for ":silent".
|
||||||
if (msg_silent != 0)
|
if (msg_silent != 0)
|
||||||
@@ -3629,8 +3635,21 @@ give_warning(char_u *message, int hl)
|
|||||||
keep_msg_attr = HL_ATTR(HLF_W);
|
keep_msg_attr = HL_ATTR(HLF_W);
|
||||||
else
|
else
|
||||||
keep_msg_attr = 0;
|
keep_msg_attr = 0;
|
||||||
if (msg_attr((char *)message, keep_msg_attr) && msg_scrolled == 0)
|
|
||||||
|
if (with_source)
|
||||||
|
{
|
||||||
|
// Do what msg() does, but with a column offset if the warning should
|
||||||
|
// be after the mode message.
|
||||||
|
msg_start();
|
||||||
|
msg_source(HL_ATTR(HLF_W));
|
||||||
|
msg_puts(" ");
|
||||||
|
msg_puts_attr((char *)message, HL_ATTR(HLF_W) | MSG_HIST);
|
||||||
|
msg_clr_eos();
|
||||||
|
(void)msg_end();
|
||||||
|
}
|
||||||
|
else if (msg_attr((char *)message, keep_msg_attr) && msg_scrolled == 0)
|
||||||
set_keep_msg(message, keep_msg_attr);
|
set_keep_msg(message, keep_msg_attr);
|
||||||
|
|
||||||
msg_didout = FALSE; // overwrite this message
|
msg_didout = FALSE; // overwrite this message
|
||||||
msg_nowait = TRUE; // don't wait for this message
|
msg_nowait = TRUE; // don't wait for this message
|
||||||
msg_col = 0;
|
msg_col = 0;
|
||||||
|
@@ -69,6 +69,7 @@ void verbose_leave_scroll(void);
|
|||||||
void verbose_stop(void);
|
void verbose_stop(void);
|
||||||
int verbose_open(void);
|
int verbose_open(void);
|
||||||
void give_warning(char_u *message, int hl);
|
void give_warning(char_u *message, int hl);
|
||||||
|
void give_warning_with_source(char_u *message, int hl, int with_source);
|
||||||
void give_warning2(char_u *message, char_u *a1, int hl);
|
void give_warning2(char_u *message, char_u *a1, int hl);
|
||||||
void msg_advance(int col);
|
void msg_advance(int col);
|
||||||
int do_dialog(int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield, int ex_cmd);
|
int do_dialog(int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield, int ex_cmd);
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
" Tests for user defined commands
|
" Tests for user defined commands
|
||||||
|
|
||||||
|
source vim9.vim
|
||||||
|
|
||||||
" Test for <mods> in user defined commands
|
" Test for <mods> in user defined commands
|
||||||
function Test_cmdmods()
|
function Test_cmdmods()
|
||||||
let g:mods = ''
|
let g:mods = ''
|
||||||
@@ -270,13 +272,29 @@ func Test_CmdErrors()
|
|||||||
call assert_fails('com! -complete=custom DoCmd :', 'E467:')
|
call assert_fails('com! -complete=custom DoCmd :', 'E467:')
|
||||||
call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
|
call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
|
||||||
call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
|
call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
|
||||||
call assert_fails('com! -complete=file DoCmd :', 'E1208:')
|
|
||||||
call assert_fails('com! -nargs=0 -complete=file DoCmd :', 'E1208:')
|
|
||||||
call assert_fails('com! -nargs=x DoCmd :', 'E176:')
|
call assert_fails('com! -nargs=x DoCmd :', 'E176:')
|
||||||
call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
|
call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
|
||||||
call assert_fails('com! -count=x DoCmd :', 'E178:')
|
call assert_fails('com! -count=x DoCmd :', 'E178:')
|
||||||
call assert_fails('com! -range=x DoCmd :', 'E178:')
|
call assert_fails('com! -range=x DoCmd :', 'E178:')
|
||||||
|
|
||||||
|
com! -complete=file DoCmd :
|
||||||
|
call assert_match('E1208:', v:warningmsg)
|
||||||
|
let v:warningmsg = ''
|
||||||
|
com! -nargs=0 -complete=file DoCmd :
|
||||||
|
call assert_match('E1208:', v:warningmsg)
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
com! -complete=file DoCmd :
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E1208', 2)
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
com! -nargs=0 -complete=file DoCmd :
|
||||||
|
END
|
||||||
|
call CheckScriptFailure(lines, 'E1208', 2)
|
||||||
|
|
||||||
com! -nargs=0 DoCmd :
|
com! -nargs=0 DoCmd :
|
||||||
call assert_fails('DoCmd x', 'E488:')
|
call assert_fails('DoCmd x', 'E488:')
|
||||||
|
|
||||||
|
@@ -1027,7 +1027,15 @@ ex_command(exarg_T *eap)
|
|||||||
&& STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0))
|
&& STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0))
|
||||||
emsg(_("E841: Reserved name, cannot be used for user defined command"));
|
emsg(_("E841: Reserved name, cannot be used for user defined command"));
|
||||||
else if (compl > 0 && (argt & EX_EXTRA) == 0)
|
else if (compl > 0 && (argt & EX_EXTRA) == 0)
|
||||||
emsg(_(e_complete_used_without_nargs));
|
{
|
||||||
|
// Some plugins rely on silently ignoring the mistake, only make this
|
||||||
|
// an error in Vim9 script.
|
||||||
|
if (in_vim9script())
|
||||||
|
emsg(_(e_complete_used_without_nargs));
|
||||||
|
else
|
||||||
|
give_warning_with_source(
|
||||||
|
(char_u *)_(e_complete_used_without_nargs), TRUE, TRUE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
|
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
|
||||||
addr_type_arg, eap->forceit);
|
addr_type_arg, eap->forceit);
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
3149,
|
||||||
/**/
|
/**/
|
||||||
3148,
|
3148,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user