0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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)
This commit is contained in:
Bram Moolenaar
2022-07-26 17:23:47 +01:00
parent 0494789ece
commit c2842adfb2
3 changed files with 23 additions and 1 deletions

View File

@@ -842,6 +842,16 @@ func Test_cmdline_complete_user_cmd()
delcommand Foo
endfunc
func Test_complete_user_cmd()
command FooBar echo 'global'
command -buffer FooBar echo 'local'
call feedkeys(":Foo\<C-A>\<Home>\"\<CR>", 'tx')
call assert_equal('"FooBar', @:)
delcommand -buffer FooBar
delcommand FooBar
endfunc
func s:ScriptLocalFunction()
echo 'yes'
endfunc

View File

@@ -363,9 +363,19 @@ get_user_commands(expand_T *xp UNUSED, int idx)
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
idx -= buf->b_ucmds.ga_len;
if (idx < ucmds.ga_len)
return USER_CMD(idx)->uc_name;
{
int i;
char_u *name = USER_CMD(idx)->uc_name;
for (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 (char_u *)"";
return name;
}
return NULL;
}

View File

@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
81,
/**/
80,
/**/