vim-patch:9.0.0081: command line completion of user command may have duplicates (#19529)

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 vim/vim#10797)
c2842adfb2
This commit is contained in:
zeertzjq
2022-07-27 07:25:47 +08:00
committed by GitHub
parent 2fdb0de197
commit 890d4023cd
2 changed files with 20 additions and 1 deletions

View File

@@ -6788,9 +6788,18 @@ char *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx)
if (idx < buf->b_ucmds.ga_len) {
return (char *)USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
}
idx -= buf->b_ucmds.ga_len;
if (idx < ucmds.ga_len) {
return (char *)USER_CMD(idx)->uc_name;
char *name = (char *)USER_CMD(idx)->uc_name;
for (int i = 0; i < buf->b_ucmds.ga_len; i++) {
if (STRCMP(name, USER_CMD_GA(&buf->b_ucmds, i)->uc_name) == 0) {
// global command is overruled by buffer-local one
return "";
}
}
return name;
}
return NULL;
}