aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2022-01-29 17:00:37 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2022-01-30 22:25:08 +0000
commitf8f0f14db2e8096e77ed60171d360ac2605b7c80 (patch)
tree45411434005647922f9241a1940cef78938a07b5 /src/nvim/ex_docmd.c
parenta28a9aec635676873e18e1ffe8d2334dd00a7ad3 (diff)
downloadrneovim-f8f0f14db2e8096e77ed60171d360ac2605b7c80.tar.gz
rneovim-f8f0f14db2e8096e77ed60171d360ac2605b7c80.tar.bz2
rneovim-f8f0f14db2e8096e77ed60171d360ac2605b7c80.zip
vim-patch:8.2.3433: :delcommand does not take a -buffer option
Problem: :delcommand does not take a -buffer option. Solution: Add the -buffer option. https://github.com/vim/vim/commit/bdcba24d8597abd5af509c2fb9206e64e713c711
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index c30d58a8eb..1f416d9f57 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -78,6 +78,10 @@
#include "nvim/vim.h"
#include "nvim/window.h"
+static char *e_no_such_user_defined_command_str = N_("E184: No such user-defined command: %s");
+static char *e_no_such_user_defined_command_in_current_buffer_str
+ = N_("E1237: No such user-defined command in current buffer: %s");
+
static int quitmore = 0;
static bool ex_pressedreturn = false;
@@ -5737,26 +5741,36 @@ static void ex_delcommand(exarg_T *eap)
{
int i = 0;
ucmd_T *cmd = NULL;
- int cmp = -1;
+ int res = -1;
garray_T *gap;
+ const char_u *arg = eap->arg;
+ bool buffer_only = false;
+
+ if (STRNCMP(arg, "-buffer", 7) == 0 && ascii_iswhite(arg[7])) {
+ buffer_only = true;
+ arg = skipwhite(arg + 7);
+ }
gap = &curbuf->b_ucmds;
for (;;) {
for (i = 0; i < gap->ga_len; i++) {
cmd = USER_CMD_GA(gap, i);
- cmp = STRCMP(eap->arg, cmd->uc_name);
- if (cmp <= 0) {
+ res = STRCMP(arg, cmd->uc_name);
+ if (res <= 0) {
break;
}
}
- if (gap == &ucmds || cmp == 0) {
+ if (gap == &ucmds || res == 0 || buffer_only) {
break;
}
gap = &ucmds;
}
- if (cmp != 0) {
- semsg(_("E184: No such user-defined command: %s"), eap->arg);
+ if (res != 0) {
+ semsg(_(buffer_only
+ ? e_no_such_user_defined_command_in_current_buffer_str
+ : e_no_such_user_defined_command_str),
+ arg);
return;
}