summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-19 20:48:37 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-19 20:48:37 +0000
commitbed34f0a8a4e38a72a080184881bc68254a8cdc6 (patch)
treed41d7ae3339b2ada1cc155ce9010057c9c43fb43
parentf67c717e34e5553ab1c3b02b1861274cbcb78935 (diff)
downloadvim-git-bed34f0a8a4e38a72a080184881bc68254a8cdc6.tar.gz
patch 8.2.4147: E464 does not always include the offending commandv8.2.4147
Problem: E464 does not always include the offending command. Solution: Add another error message with "%s". (closes #9564)
-rw-r--r--src/errors.h2
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/testdir/test_vim9_script.vim30
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c2
5 files changed, 36 insertions, 2 deletions
diff --git a/src/errors.h b/src/errors.h
index 0d11416a1..7ad1076df 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -1148,6 +1148,8 @@ EXTERN char e_region_is_guarded_cannot_modify[]
#endif
EXTERN char e_ambiguous_use_of_user_defined_command[]
INIT(= N_("E464: Ambiguous use of user-defined command"));
+EXTERN char e_ambiguous_use_of_user_defined_command_str[]
+ INIT(= N_("E464: Ambiguous use of user-defined command: %s"));
EXTERN char e_winsize_requires_two_number_arguments[]
INIT(= N_("E465: :winsize requires two number arguments"));
EXTERN char e_winpos_requires_two_number_arguments[]
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index d8d77ce4d..5f5f60fe0 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2614,7 +2614,7 @@ doend:
if (errormsg != NULL && *errormsg != NUL && !did_emsg)
{
- if (sourcing)
+ if (sourcing || !KeyTyped)
{
if (errormsg != (char *)IObuff)
{
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 8bf2e9ef1..eb84c3589 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -3664,6 +3664,36 @@ def ProfiledNestedProfiled()
Nested()
enddef
+def Test_ambigous_command_error()
+ var lines =<< trim END
+ vim9script
+ command CmdA echomsg 'CmdA'
+ command CmdB echomsg 'CmdB'
+ Cmd
+ END
+ CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 4)
+
+ lines =<< trim END
+ vim9script
+ def Func()
+ Cmd
+ enddef
+ Func()
+ END
+ CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 1)
+
+ lines =<< trim END
+ vim9script
+ nnoremap <F3> <ScriptCmd>Cmd<CR>
+ feedkeys("\<F3>", 'xt')
+ END
+ CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 3)
+
+ delcommand CmdA
+ delcommand CmdB
+ nunmap <F3>
+enddef
+
" Execute this near the end, profiling doesn't stop until Vim exits.
" This only tests that it works, not the profiling output.
def Test_xx_profile_with_lambda()
diff --git a/src/version.c b/src/version.c
index 6babbdda6..1ca0a226c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4147,
+/**/
4146,
/**/
4145,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 89520f93b..ddb486b01 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2878,7 +2878,7 @@ compile_def_function(
if (p == NULL)
{
if (cctx.ctx_skip != SKIP_YES)
- emsg(_(e_ambiguous_use_of_user_defined_command));
+ semsg(_(e_ambiguous_use_of_user_defined_command_str), ea.cmd);
goto erret;
}