forked from aniani/vim
patch 8.2.3629: command completion in cmdline window uses global commands
Problem: Command completion in cmdline window uses global user commands, not local commands for the window where it was opened from. Solution: Use local commands. (closes #9168)
This commit is contained in:
@@ -2074,8 +2074,7 @@ get_user_var_name(expand_T *xp, int idx)
|
|||||||
ht =
|
ht =
|
||||||
#ifdef FEAT_CMDWIN
|
#ifdef FEAT_CMDWIN
|
||||||
// In cmdwin, the alternative buffer should be used.
|
// In cmdwin, the alternative buffer should be used.
|
||||||
(cmdwin_type != 0 && get_cmdline_type() == NUL) ?
|
is_in_cmdwin() ? &prevwin->w_buffer->b_vars->dv_hashtab :
|
||||||
&prevwin->w_buffer->b_vars->dv_hashtab :
|
|
||||||
#endif
|
#endif
|
||||||
&curbuf->b_vars->dv_hashtab;
|
&curbuf->b_vars->dv_hashtab;
|
||||||
if (bdone < ht->ht_used)
|
if (bdone < ht->ht_used)
|
||||||
@@ -2093,8 +2092,7 @@ get_user_var_name(expand_T *xp, int idx)
|
|||||||
ht =
|
ht =
|
||||||
#ifdef FEAT_CMDWIN
|
#ifdef FEAT_CMDWIN
|
||||||
// In cmdwin, the alternative window should be used.
|
// In cmdwin, the alternative window should be used.
|
||||||
(cmdwin_type != 0 && get_cmdline_type() == NUL) ?
|
is_in_cmdwin() ? &prevwin->w_vars->dv_hashtab :
|
||||||
&prevwin->w_vars->dv_hashtab :
|
|
||||||
#endif
|
#endif
|
||||||
&curwin->w_vars->dv_hashtab;
|
&curwin->w_vars->dv_hashtab;
|
||||||
if (wdone < ht->ht_used)
|
if (wdone < ht->ht_used)
|
||||||
|
@@ -4485,6 +4485,15 @@ open_cmdwin(void)
|
|||||||
|
|
||||||
return cmdwin_result;
|
return cmdwin_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if in the cmdwin, not editing the command line.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
is_in_cmdwin(void)
|
||||||
|
{
|
||||||
|
return cmdwin_type != 0 && get_cmdline_type() == NUL;
|
||||||
|
}
|
||||||
#endif // FEAT_CMDWIN
|
#endif // FEAT_CMDWIN
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -38,6 +38,7 @@ int get_cmdline_type(void);
|
|||||||
int get_cmdline_firstc(void);
|
int get_cmdline_firstc(void);
|
||||||
int get_list_range(char_u **str, int *num1, int *num2);
|
int get_list_range(char_u **str, int *num1, int *num2);
|
||||||
char *check_cedit(void);
|
char *check_cedit(void);
|
||||||
|
int is_in_cmdwin(void);
|
||||||
char_u *script_get(exarg_T *eap, char_u *cmd);
|
char_u *script_get(exarg_T *eap, char_u *cmd);
|
||||||
void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog, int secret);
|
void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog, int secret);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@@ -373,6 +373,14 @@ func Test_compl_feedkeys()
|
|||||||
set completeopt&
|
set completeopt&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func s:ComplInCmdwin_GlobalCompletion(a, l, p)
|
||||||
|
return 'global'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func s:ComplInCmdwin_LocalCompletion(a, l, p)
|
||||||
|
return 'local'
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_compl_in_cmdwin()
|
func Test_compl_in_cmdwin()
|
||||||
CheckFeature cmdwin
|
CheckFeature cmdwin
|
||||||
|
|
||||||
@@ -411,6 +419,47 @@ func Test_compl_in_cmdwin()
|
|||||||
call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
|
call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
|
||||||
call assert_equal('b:test_', input)
|
call assert_equal('b:test_', input)
|
||||||
|
|
||||||
|
|
||||||
|
" Argument completion of buffer-local command
|
||||||
|
func s:ComplInCmdwin_GlobalCompletionList(a, l, p)
|
||||||
|
return ['global']
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func s:ComplInCmdwin_LocalCompletionList(a, l, p)
|
||||||
|
return ['local']
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func s:ComplInCmdwin_CheckCompletion(arg)
|
||||||
|
call assert_equal('local', a:arg)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion
|
||||||
|
\ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
|
||||||
|
com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion
|
||||||
|
\ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
|
||||||
|
call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
|
||||||
|
|
||||||
|
com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList
|
||||||
|
\ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
|
||||||
|
com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList
|
||||||
|
\ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
|
||||||
|
|
||||||
|
call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
|
||||||
|
|
||||||
|
func! s:ComplInCmdwin_CheckCompletion(arg)
|
||||||
|
call assert_equal('global', a:arg)
|
||||||
|
endfunc
|
||||||
|
new
|
||||||
|
call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
|
||||||
|
quit
|
||||||
|
|
||||||
|
delfunc s:ComplInCmdwin_GlobalCompletion
|
||||||
|
delfunc s:ComplInCmdwin_LocalCompletion
|
||||||
|
delfunc s:ComplInCmdwin_GlobalCompletionList
|
||||||
|
delfunc s:ComplInCmdwin_LocalCompletionList
|
||||||
|
delfunc s:ComplInCmdwin_CheckCompletion
|
||||||
|
|
||||||
|
delcom -buffer TestCommand
|
||||||
delcom TestCommand
|
delcom TestCommand
|
||||||
delcom GetInput
|
delcom GetInput
|
||||||
unlet w:test_winvar
|
unlet w:test_winvar
|
||||||
|
@@ -141,7 +141,11 @@ find_ucmd(
|
|||||||
/*
|
/*
|
||||||
* Look for buffer-local user commands first, then global ones.
|
* Look for buffer-local user commands first, then global ones.
|
||||||
*/
|
*/
|
||||||
gap = &curbuf->b_ucmds;
|
gap =
|
||||||
|
#ifdef FEAT_CMDWIN
|
||||||
|
is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :
|
||||||
|
#endif
|
||||||
|
&curbuf->b_ucmds;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
for (j = 0; j < gap->ga_len; ++j)
|
for (j = 0; j < gap->ga_len; ++j)
|
||||||
@@ -303,7 +307,7 @@ get_user_commands(expand_T *xp UNUSED, int idx)
|
|||||||
// In cmdwin, the alternative buffer should be used.
|
// In cmdwin, the alternative buffer should be used.
|
||||||
buf_T *buf =
|
buf_T *buf =
|
||||||
#ifdef FEAT_CMDWIN
|
#ifdef FEAT_CMDWIN
|
||||||
(cmdwin_type != 0 && get_cmdline_type() == NUL) ? prevwin->w_buffer :
|
is_in_cmdwin() ? prevwin->w_buffer :
|
||||||
#endif
|
#endif
|
||||||
curbuf;
|
curbuf;
|
||||||
|
|
||||||
@@ -330,10 +334,9 @@ get_user_command_name(int idx, int cmdidx)
|
|||||||
// In cmdwin, the alternative buffer should be used.
|
// In cmdwin, the alternative buffer should be used.
|
||||||
buf_T *buf =
|
buf_T *buf =
|
||||||
#ifdef FEAT_CMDWIN
|
#ifdef FEAT_CMDWIN
|
||||||
(cmdwin_type != 0 && get_cmdline_type() == NUL)
|
is_in_cmdwin() ? prevwin->w_buffer :
|
||||||
? prevwin->w_buffer :
|
|
||||||
#endif
|
#endif
|
||||||
curbuf;
|
curbuf;
|
||||||
|
|
||||||
if (idx < buf->b_ucmds.ga_len)
|
if (idx < buf->b_ucmds.ga_len)
|
||||||
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
|
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
|
||||||
@@ -420,10 +423,9 @@ uc_list(char_u *name, size_t name_len)
|
|||||||
// In cmdwin, the alternative buffer should be used.
|
// In cmdwin, the alternative buffer should be used.
|
||||||
gap =
|
gap =
|
||||||
#ifdef FEAT_CMDWIN
|
#ifdef FEAT_CMDWIN
|
||||||
(cmdwin_type != 0 && get_cmdline_type() == NUL) ?
|
is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :
|
||||||
&prevwin->w_buffer->b_ucmds :
|
|
||||||
#endif
|
#endif
|
||||||
&curbuf->b_ucmds;
|
&curbuf->b_ucmds;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
for (i = 0; i < gap->ga_len; ++i)
|
for (i = 0; i < gap->ga_len; ++i)
|
||||||
|
@@ -757,6 +757,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 */
|
||||||
|
/**/
|
||||||
|
3629,
|
||||||
/**/
|
/**/
|
||||||
3628,
|
3628,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user