Mercurial > vim
comparison src/usercmd.c @ 25757:589226a5f317 v8.2.3414
patch 8.2.3414: fullcommand() gives wrong name with buffer-local user command
Commit: https://github.com/vim/vim/commit/80c88eac5a81dd9f1a96fc80cb8aab6c84fe7b86
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 8 14:29:46 2021 +0200
patch 8.2.3414: fullcommand() gives wrong name with buffer-local user command
Problem: fullcommand() gives the wrong name if there is a buffer-local user
command. (Naohiro Ono)
Solution: Use a separate function to get the user command name.
(closes #8840)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 08 Sep 2021 14:30:05 +0200 |
parents | b9419c9d3da6 |
children | 60e4892dfa45 |
comparison
equal
deleted
inserted
replaced
25756:912ae2bec55b | 25757:589226a5f317 |
---|---|
287 // And finally comes a normal command | 287 // And finally comes a normal command |
288 return skipwhite(p); | 288 return skipwhite(p); |
289 } | 289 } |
290 | 290 |
291 char_u * | 291 char_u * |
292 get_user_command_name(int idx) | 292 expand_user_command_name(int idx) |
293 { | 293 { |
294 return get_user_commands(NULL, idx - (int)CMD_SIZE); | 294 return get_user_commands(NULL, idx - (int)CMD_SIZE); |
295 } | 295 } |
296 | 296 |
297 /* | 297 /* |
310 if (idx < buf->b_ucmds.ga_len) | 310 if (idx < buf->b_ucmds.ga_len) |
311 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; | 311 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; |
312 idx -= buf->b_ucmds.ga_len; | 312 idx -= buf->b_ucmds.ga_len; |
313 if (idx < ucmds.ga_len) | 313 if (idx < ucmds.ga_len) |
314 return USER_CMD(idx)->uc_name; | 314 return USER_CMD(idx)->uc_name; |
315 return NULL; | |
316 } | |
317 | |
318 /* | |
319 * Get the name of user command "idx". "cmdidx" can be CMD_USER or | |
320 * CMD_USER_BUF. | |
321 * Returns NULL if the command is not found. | |
322 */ | |
323 char_u * | |
324 get_user_command_name(int idx, int cmdidx) | |
325 { | |
326 if (cmdidx == CMD_USER && idx < ucmds.ga_len) | |
327 return USER_CMD(idx)->uc_name; | |
328 if (cmdidx == CMD_USER_BUF) | |
329 { | |
330 // In cmdwin, the alternative buffer should be used. | |
331 buf_T *buf = | |
332 #ifdef FEAT_CMDWIN | |
333 (cmdwin_type != 0 && get_cmdline_type() == NUL) | |
334 ? prevwin->w_buffer : | |
335 #endif | |
336 curbuf; | |
337 | |
338 if (idx < buf->b_ucmds.ga_len) | |
339 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; | |
340 } | |
315 return NULL; | 341 return NULL; |
316 } | 342 } |
317 | 343 |
318 /* | 344 /* |
319 * Function given to ExpandGeneric() to obtain the list of user address type | 345 * Function given to ExpandGeneric() to obtain the list of user address type |