Compare commits

...

2 Commits

Author SHA1 Message Date
Yegappan Lakshmanan
4d03d87000 patch 8.2.4366: not enough tests for command line completion
Problem:    Not enough tests for command line completion.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #9760)
2022-02-13 11:45:09 +00:00
Bram Moolenaar
cdf0485969 patch 8.2.4365: sticky command modifiers are too sticky
Problem:    sticky command modifiers are too sticky.
Solution:   Do not apply command modifiers to a called function. (closes #9751)
2022-02-12 22:13:06 +00:00
6 changed files with 84 additions and 0 deletions

View File

@@ -50,6 +50,9 @@ sort_func_compare(const void *s1, const void *s2)
return STRCMP(p1, p2);
}
/*
* Escape special characters in the cmdline completion matches.
*/
static void
ExpandEscape(
expand_T *xp,

View File

@@ -409,6 +409,12 @@ func Test_getcompletion()
call assert_equal(cmds, l)
let l = getcompletion('list ', 'sign')
call assert_equal(['Testing'], l)
let l = getcompletion('de*', 'sign')
call assert_equal(['define'], l)
let l = getcompletion('p?', 'sign')
call assert_equal(['place'], l)
let l = getcompletion('j.', 'sign')
call assert_equal(['jump'], l)
endif
" Command line completion tests
@@ -461,6 +467,18 @@ func Test_getcompletion()
call delete('Xtags')
set tags&
edit a~b
enew
call assert_equal(['a~b'], getcompletion('a~', 'buffer'))
bw a~b
if has('unix')
edit Xtest\
enew
call assert_equal(['Xtest\'], getcompletion('Xtest\', 'buffer'))
bw Xtest\
endif
call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:')
call assert_fails('call getcompletion("", "burp")', 'E475:')
call assert_fails('call getcompletion("abc", [])', 'E475:')
@@ -1006,6 +1024,25 @@ func Test_cmdline_complete_various()
call feedkeys(":chist\<Esc>\<Esc>", 'xt')
call assert_equal('"g/a\xb/clearjumps', @:)
set wildchar&
" should be able to complete a file name that starts with a '~'.
if has('unix')
call writefile([], '~Xtest')
call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e \~Xtest', @:)
call delete('~Xtest')
endif
endfunc
" Test for 'wildignorecase'
func Test_cmdline_wildignorecase()
CheckUnix
call writefile([], 'XTEST')
set wildignorecase
call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e XTEST', @:)
set wildignorecase&
call delete('XTEST')
endfunc
func Test_cmdline_write_alternatefile()
@@ -1627,6 +1664,14 @@ func Test_wildmode()
call assert_equal('AAA AAAA AAAAA', g:Sline)
call assert_equal('"b A', @:)
" when using longest completion match, matches shorter than the argument
" should be ignored (happens with :help)
set wildmode=longest,full
set wildmenu
call feedkeys(":help a*\t\<C-B>\"\<CR>", 'xt')
call assert_equal('"help a', @:)
set wildmenu&
%argdelete
delcommand MyCmd
delfunc T

View File

@@ -384,6 +384,17 @@ func Test_CmdCompletion()
com! -nargs=? -complete=custom,min DoCmd
call assert_fails("call feedkeys(':DoCmd \t', 'tx')", 'E118:')
" custom completion for a pattern with a backslash
let g:ArgLead = ''
func! CustCompl(A, L, P)
let g:ArgLead = a:A
return ['one', 'two', 'three']
endfunc
com! -nargs=? -complete=customlist,CustCompl DoCmd
call feedkeys(":DoCmd a\\\t", 'xt')
call assert_equal('a\', g:ArgLead)
delfunc CustCompl
delcom DoCmd
endfunc

View File

@@ -118,6 +118,20 @@ def Test_cmdmod_execute()
END
v9.CheckScriptSuccess(lines)
delete('Xvim9import.vim')
# "legacy" does not aply to a called function
lines =<< trim END
vim9script
def g:TheFunc()
if exists('something')
echo 'yes'
endif
enddef
legacy exe 'call g:TheFunc()'
END
v9.CheckScriptSuccess(lines)
delfunc g:TheFunc
enddef
def Test_edit_wildcards()

View File

@@ -2513,6 +2513,7 @@ call_user_func(
{
sctx_T save_current_sctx;
int using_sandbox = FALSE;
int save_sticky_cmdmod_flags = sticky_cmdmod_flags;
funccall_T *fc;
int save_did_emsg;
int default_arg_err = FALSE;
@@ -2569,6 +2570,7 @@ call_user_func(
if (do_profiling == PROF_YES)
profile_may_start_func(&profile_info, fp, caller);
#endif
sticky_cmdmod_flags = 0;
call_def_function(fp, argcount, argvars, funcexe->fe_partial, rettv);
funcdepth_decrement();
#ifdef FEAT_PROFILE
@@ -2578,6 +2580,7 @@ call_user_func(
#endif
current_funccal = fc->caller;
free_funccal(fc);
sticky_cmdmod_flags = save_sticky_cmdmod_flags;
return;
}
@@ -2797,6 +2800,9 @@ call_user_func(
fc->caller == NULL ? NULL : fc->caller->func);
#endif
// "legacy" does not apply to commands in the function
sticky_cmdmod_flags = 0;
save_current_sctx = current_sctx;
current_sctx = fp->uf_script_ctx;
save_did_emsg = did_emsg;
@@ -2889,6 +2895,7 @@ call_user_func(
#endif
if (using_sandbox)
--sandbox;
sticky_cmdmod_flags = save_sticky_cmdmod_flags;
if (p_verbose >= 12 && SOURCING_NAME != NULL)
{

View File

@@ -750,6 +750,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4366,
/**/
4365,
/**/
4364,
/**/