Skip to content

Commit eac784e

Browse files
committed
patch 7.4.2110
Problem: When there is an CmdUndefined autocmd then the error for a missing command is E464 instead of E492. (Manuel Ortega) Solution: Don't let the pointer be NULL.
1 parent ad9c2a0 commit eac784e

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,7 @@ do_one_cmd(
23432343
vim_free(p);
23442344
/* If the autocommands did something and didn't cause an error, try
23452345
* finding the command again. */
2346-
p = (ret && !aborting()) ? find_command(&ea, NULL) : NULL;
2346+
p = (ret && !aborting()) ? find_command(&ea, NULL) : ea.cmd;
23472347
}
23482348
#endif
23492349

src/testdir/test_usercommands.vim

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,33 @@ function Test_cmdmods()
4646
delcommand MyQCmd
4747
unlet g:mods
4848
endfunction
49+
50+
func Test_Ambiguous()
51+
command Doit let g:didit = 'yes'
52+
command Dothat let g:didthat = 'also'
53+
call assert_fails('Do', 'E464:')
54+
Doit
55+
call assert_equal('yes', g:didit)
56+
Dothat
57+
call assert_equal('also', g:didthat)
58+
unlet g:didit
59+
unlet g:didthat
60+
61+
delcommand Doit
62+
Do
63+
call assert_equal('also', g:didthat)
64+
delcommand Dothat
65+
endfunc
66+
67+
func Test_CmdUndefined()
68+
call assert_fails('Doit', 'E492:')
69+
au CmdUndefined Doit :command Doit let g:didit = 'yes'
70+
Doit
71+
call assert_equal('yes', g:didit)
72+
delcommand Doit
73+
74+
call assert_fails('Dothat', 'E492:')
75+
au CmdUndefined * let g:didnot = 'yes'
76+
call assert_fails('Dothat', 'E492:')
77+
call assert_equal('yes', g:didnot)
78+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ static char *(features[]) =
758758

759759
static int included_patches[] =
760760
{ /* Add new patch number below this line */
761+
/**/
762+
2110,
761763
/**/
762764
2109,
763765
/**/

0 commit comments

Comments
 (0)