ht =
#ifdef FEAT_CMDWIN
// In cmdwin, the alternative buffer should be used.
- (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
- &prevwin->w_buffer->b_vars->dv_hashtab :
+ is_in_cmdwin() ? &prevwin->w_buffer->b_vars->dv_hashtab :
#endif
&curbuf->b_vars->dv_hashtab;
if (bdone < ht->ht_used)
ht =
#ifdef FEAT_CMDWIN
// In cmdwin, the alternative window should be used.
- (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
- &prevwin->w_vars->dv_hashtab :
+ is_in_cmdwin() ? &prevwin->w_vars->dv_hashtab :
#endif
&curwin->w_vars->dv_hashtab;
if (wdone < ht->ht_used)
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
/*
int get_cmdline_firstc(void);
int get_list_range(char_u **str, int *num1, int *num2);
char *check_cedit(void);
+int is_in_cmdwin(void);
char_u *script_get(exarg_T *eap, char_u *cmd);
void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog, int secret);
/* vim: set ft=c : */
set completeopt&
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()
CheckFeature cmdwin
call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
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 GetInput
unlet w:test_winvar
/*
* 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 (j = 0; j < gap->ga_len; ++j)
// In cmdwin, the alternative buffer should be used.
buf_T *buf =
#ifdef FEAT_CMDWIN
- (cmdwin_type != 0 && get_cmdline_type() == NUL) ? prevwin->w_buffer :
+ is_in_cmdwin() ? prevwin->w_buffer :
#endif
curbuf;
// In cmdwin, the alternative buffer should be used.
buf_T *buf =
#ifdef FEAT_CMDWIN
- (cmdwin_type != 0 && get_cmdline_type() == NUL)
- ? prevwin->w_buffer :
+ is_in_cmdwin() ? prevwin->w_buffer :
#endif
- curbuf;
+ curbuf;
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
// In cmdwin, the alternative buffer should be used.
gap =
#ifdef FEAT_CMDWIN
- (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
- &prevwin->w_buffer->b_ucmds :
+ is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :
#endif
- &curbuf->b_ucmds;
+ &curbuf->b_ucmds;
for (;;)
{
for (i = 0; i < gap->ga_len; ++i)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 3629,
/**/
3628,
/**/