forked from aniani/vim
patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Problem: Completion in cmdwin does not work for buffer-local commands. Solution: Use the right buffer. (closes #4711)
This commit is contained in:
@@ -313,3 +313,21 @@ func Test_compl_feedkeys()
|
|||||||
bwipe!
|
bwipe!
|
||||||
set completeopt&
|
set completeopt&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_compl_in_cmdwin()
|
||||||
|
set wildmenu wildchar=<Tab>
|
||||||
|
com! -nargs=1 -complete=command GetInput let input = <q-args>
|
||||||
|
com! -buffer TestCommand echo 'TestCommand'
|
||||||
|
|
||||||
|
let input = ''
|
||||||
|
call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
|
||||||
|
call assert_equal('TestCommand', input)
|
||||||
|
|
||||||
|
let input = ''
|
||||||
|
call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
|
||||||
|
call assert_equal('T', input)
|
||||||
|
|
||||||
|
delcom TestCommand
|
||||||
|
delcom GetInput
|
||||||
|
set wildmenu& wildchar&
|
||||||
|
endfunc
|
||||||
|
@@ -309,9 +309,16 @@ get_user_command_name(int idx)
|
|||||||
char_u *
|
char_u *
|
||||||
get_user_commands(expand_T *xp UNUSED, int idx)
|
get_user_commands(expand_T *xp UNUSED, int idx)
|
||||||
{
|
{
|
||||||
if (idx < curbuf->b_ucmds.ga_len)
|
// In cmdwin, the alternative buffer should be used.
|
||||||
return USER_CMD_GA(&curbuf->b_ucmds, idx)->uc_name;
|
buf_T *buf =
|
||||||
idx -= curbuf->b_ucmds.ga_len;
|
#ifdef FEAT_CMDWIN
|
||||||
|
(cmdwin_type != 0 && get_cmdline_type() == NUL) ? prevwin->w_buffer :
|
||||||
|
#endif
|
||||||
|
curbuf;
|
||||||
|
|
||||||
|
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)
|
if (idx < ucmds.ga_len)
|
||||||
return USER_CMD(idx)->uc_name;
|
return USER_CMD(idx)->uc_name;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -395,7 +402,13 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
long a;
|
long a;
|
||||||
garray_T *gap;
|
garray_T *gap;
|
||||||
|
|
||||||
gap = &curbuf->b_ucmds;
|
/* In cmdwin, the alternative buffer should be used. */
|
||||||
|
gap =
|
||||||
|
#ifdef FEAT_CMDWIN
|
||||||
|
(cmdwin_type != 0 && get_cmdline_type() == NUL) ?
|
||||||
|
&prevwin->w_buffer->b_ucmds :
|
||||||
|
#endif
|
||||||
|
&curbuf->b_ucmds;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
for (i = 0; i < gap->ga_len; ++i)
|
for (i = 0; i < gap->ga_len; ++i)
|
||||||
|
@@ -777,6 +777,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1732,
|
||||||
/**/
|
/**/
|
||||||
1731,
|
1731,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user