comparison src/usercmd.c @ 25796:60e4892dfa45 v8.2.3433

patch 8.2.3433: :delcommand does not take a -buffer option Commit: https://github.com/vim/vim/commit/bdcba24d8597abd5af509c2fb9206e64e713c711 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 12 20:58:02 2021 +0200 patch 8.2.3433: :delcommand does not take a -buffer option Problem: :delcommand does not take a -buffer option. Solution: Add the -buffer option.
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Sep 2021 21:00:04 +0200
parents 589226a5f317
children d079ab2ba260
comparison
equal deleted inserted replaced
25795:f0093634cf43 25796:60e4892dfa45
1160 void 1160 void
1161 ex_delcommand(exarg_T *eap) 1161 ex_delcommand(exarg_T *eap)
1162 { 1162 {
1163 int i = 0; 1163 int i = 0;
1164 ucmd_T *cmd = NULL; 1164 ucmd_T *cmd = NULL;
1165 int cmp = -1; 1165 int res = -1;
1166 garray_T *gap; 1166 garray_T *gap;
1167 char_u *arg = eap->arg;
1168 int buffer_only = FALSE;
1169
1170 if (STRNCMP(arg, "-buffer", 7) == 0 && VIM_ISWHITE(arg[7]))
1171 {
1172 buffer_only = TRUE;
1173 arg = skipwhite(arg + 7);
1174 }
1167 1175
1168 gap = &curbuf->b_ucmds; 1176 gap = &curbuf->b_ucmds;
1169 for (;;) 1177 for (;;)
1170 { 1178 {
1171 for (i = 0; i < gap->ga_len; ++i) 1179 for (i = 0; i < gap->ga_len; ++i)
1172 { 1180 {
1173 cmd = USER_CMD_GA(gap, i); 1181 cmd = USER_CMD_GA(gap, i);
1174 cmp = STRCMP(eap->arg, cmd->uc_name); 1182 res = STRCMP(arg, cmd->uc_name);
1175 if (cmp <= 0) 1183 if (res <= 0)
1176 break; 1184 break;
1177 } 1185 }
1178 if (gap == &ucmds || cmp == 0) 1186 if (gap == &ucmds || res == 0 || buffer_only)
1179 break; 1187 break;
1180 gap = &ucmds; 1188 gap = &ucmds;
1181 } 1189 }
1182 1190
1183 if (cmp != 0) 1191 if (res != 0)
1184 { 1192 {
1185 semsg(_("E184: No such user-defined command: %s"), eap->arg); 1193 semsg(_(buffer_only
1194 ? e_no_such_user_defined_command_in_current_buffer_str
1195 : e_no_such_user_defined_command_str), arg);
1186 return; 1196 return;
1187 } 1197 }
1188 1198
1189 vim_free(cmd->uc_name); 1199 vim_free(cmd->uc_name);
1190 vim_free(cmd->uc_rep); 1200 vim_free(cmd->uc_rep);