comparison src/usercmd.c @ 29479:5c390aa28f44 v9.0.0081

patch 9.0.0081: command line completion of user command may have duplicates Commit: https://github.com/vim/vim/commit/c2842adfb2ca0637f13e2793fefa18e7818684f9 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 26 17:23:47 2022 +0100 patch 9.0.0081: command line completion of user command may have duplicates Problem: Command line completion of user command may have duplicates. (Dani Dickstein) Solution: Skip global user command if an identical buffer-local one is defined. (closes #10797)
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Jul 2022 18:30:03 +0200
parents 48b086982c01
children 578e71f924fe
comparison
equal deleted inserted replaced
29478:5d3972281e92 29479:5c390aa28f44
361 // In cmdwin, the alternative buffer should be used. 361 // In cmdwin, the alternative buffer should be used.
362 buf_T *buf = prevwin_curwin()->w_buffer; 362 buf_T *buf = prevwin_curwin()->w_buffer;
363 363
364 if (idx < buf->b_ucmds.ga_len) 364 if (idx < buf->b_ucmds.ga_len)
365 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; 365 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
366
366 idx -= buf->b_ucmds.ga_len; 367 idx -= buf->b_ucmds.ga_len;
367 if (idx < ucmds.ga_len) 368 if (idx < ucmds.ga_len)
368 return USER_CMD(idx)->uc_name; 369 {
370 int i;
371 char_u *name = USER_CMD(idx)->uc_name;
372
373 for (i = 0; i < buf->b_ucmds.ga_len; ++i)
374 if (STRCMP(name, USER_CMD_GA(&buf->b_ucmds, i)->uc_name) == 0)
375 // global command is overruled by buffer-local one
376 return (char_u *)"";
377 return name;
378 }
369 return NULL; 379 return NULL;
370 } 380 }
371 381
372 #ifdef FEAT_EVAL 382 #ifdef FEAT_EVAL
373 /* 383 /*