Mercurial > vim
diff src/testdir/test_usercommands.vim @ 15125:b101b193d5ff v8.1.0573
patch 8.1.0573: cannot redefine user command without ! in same script
commit https://github.com/vim/vim/commit/55d46913084745a48749d7ac4f48930852e1d87e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 8 16:03:28 2018 +0100
patch 8.1.0573: cannot redefine user command without ! in same script
Problem: Cannot redefine user command without ! in same script
Solution: Allow redefining user command without ! in same script, like with
functions.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 08 Dec 2018 16:15:05 +0100 |
parents | 39728d503e47 |
children | 250420b35b10 |
line wrap: on
line diff
--- a/src/testdir/test_usercommands.vim +++ b/src/testdir/test_usercommands.vim @@ -90,6 +90,34 @@ func Test_Ambiguous() delcommand Dothat endfunc +func Test_redefine_on_reload() + call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists') + call assert_equal(0, exists(':ExistingCommand')) + source Xcommandexists + call assert_equal(2, exists(':ExistingCommand')) + " Redefining a command when reloading a script is OK. + source Xcommandexists + call assert_equal(2, exists(':ExistingCommand')) + + " But redefining in another script is not OK. + call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists2') + call assert_fails('source Xcommandexists2', 'E174:') + call delete('Xcommandexists2') + + " And defining twice in one script is not OK. + delcommand ExistingCommand + call assert_equal(0, exists(':ExistingCommand')) + call writefile([ + \ 'command ExistingCommand echo "yes"', + \ 'command ExistingCommand echo "no"', + \ ], 'Xcommandexists') + call assert_fails('source Xcommandexists', 'E174:') + call assert_equal(2, exists(':ExistingCommand')) + + call delete('Xcommandexists') + delcommand ExistingCommand +endfunc + func Test_CmdUndefined() call assert_fails('Doit', 'E492:') au CmdUndefined Doit :command Doit let g:didit = 'yes'