]> granicus.if.org Git - vim/commitdiff
patch 8.2.4147: E464 does not always include the offending command v8.2.4147
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Jan 2022 20:48:37 +0000 (20:48 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Jan 2022 20:48:37 +0000 (20:48 +0000)
Problem:    E464 does not always include the offending command.
Solution:   Add another error message with "%s". (closes #9564)

src/errors.h
src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 0d11416a1da735c26da5cb1a42edd84b8b8c42f3..7ad1076dfc7018258ad9b15ee374985afbf99c52 100644 (file)
@@ -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[]
index d8d77ce4d2a0225c25bc07b85ee8d71ac3b89da4..5f5f60fe0b74d5136efb88038854a66f465ec0ac 100644 (file)
@@ -2614,7 +2614,7 @@ doend:
 
     if (errormsg != NULL && *errormsg != NUL && !did_emsg)
     {
-       if (sourcing)
+       if (sourcing || !KeyTyped)
        {
            if (errormsg != (char *)IObuff)
            {
index 8bf2e9ef19eb9b135bea2fb075d6eb1576b52ece..eb84c35892aa29e2ca28f127558becef580b3da7 100644 (file)
@@ -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()
index 6babbdda6558dd12ab84acf147e6e6df8b804354..1ca0a226c2088f6bfc67c951868d1be5371c42fa 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4147,
 /**/
     4146,
 /**/
index 89520f93b8b36f9b6515a177c2a174fd37bc00af..ddb486b016bdd61c923517b96aef5eaabe8185c0 100644 (file)
@@ -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;
        }