Mercurial > vim
diff src/ex_docmd.c @ 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 | 1ef429366fd4 |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5869,9 +5869,13 @@ uc_add_command( if (cmp == 0) { - if (!force) - { - EMSG(_("E174: Command already exists: add ! to replace it")); + // Command can be replaced with "command!" and when sourcing the + // same script again, but only once. + if (!force && (cmd->uc_script_ctx.sc_sid != current_sctx.sc_sid + || cmd->uc_script_ctx.sc_seq == current_sctx.sc_seq)) + { + EMSG2(_("E174: Command already exists: add ! to replace it: %s"), + name); goto fail; }