diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-06-08 12:41:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-08 12:41:59 +0200 |
commit | f48aa68e0832e74aef19b1ac09f31bae3d231efe (patch) | |
tree | 102caf20be85af78aad8cc4695ae1e7abcf3baf3 /src/nvim/api/vimscript.c | |
parent | 3cd22a34852b7453eecb4715806cc09dcc226e0c (diff) | |
parent | c84bd9e21fb1e5c55c9c5370b07271a6ae96f19c (diff) | |
download | rneovim-f48aa68e0832e74aef19b1ac09f31bae3d231efe.tar.gz rneovim-f48aa68e0832e74aef19b1ac09f31bae3d231efe.tar.bz2 rneovim-f48aa68e0832e74aef19b1ac09f31bae3d231efe.zip |
Merge pull request #18896 from famiu/fix/nvim_create_user_command/smods
fix(nvim_create_user_command): make `smods` work with `nvim_cmd`
Diffstat (limited to 'src/nvim/api/vimscript.c')
-rw-r--r-- | src/nvim/api/vimscript.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 99ab247c2a..4b4404ea09 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -1241,10 +1241,12 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error } if (HAS_KEY(mods.verbose)) { - if (mods.verbose.type != kObjectTypeInteger || mods.verbose.data.integer <= 0) { - VALIDATION_ERROR("'mods.verbose' must be a non-negative Integer"); + if (mods.verbose.type != kObjectTypeInteger) { + VALIDATION_ERROR("'mods.verbose' must be a Integer"); + } else if (mods.verbose.data.integer >= 0) { + // Silently ignore negative integers to allow mods.verbose to be set to -1. + cmdinfo.verbose = mods.verbose.data.integer; } - cmdinfo.verbose = mods.verbose.data.integer; } bool vertical; @@ -1256,8 +1258,10 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error VALIDATION_ERROR("'mods.split' must be a String"); } - if (STRCMP(mods.split.data.string.data, "aboveleft") == 0 - || STRCMP(mods.split.data.string.data, "leftabove") == 0) { + if (*mods.split.data.string.data == NUL) { + // Empty string, do nothing. + } else if (STRCMP(mods.split.data.string.data, "aboveleft") == 0 + || STRCMP(mods.split.data.string.data, "leftabove") == 0) { cmdinfo.cmdmod.split |= WSP_ABOVE; } else if (STRCMP(mods.split.data.string.data, "belowright") == 0 || STRCMP(mods.split.data.string.data, "rightbelow") == 0) { |