diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 07:29:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-21 07:29:49 +0800 |
commit | 694814cdd54ac245d1f4d2c28dce7e9132fcb616 (patch) | |
tree | 70258002f855c8b921998bc1d90b992840dc5a1f /test | |
parent | ac99e63d73df84cc20766ad86655724f3a0345b9 (diff) | |
download | rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.tar.gz rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.tar.bz2 rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.zip |
vim-patch:9.0.1774: no support for custom cmdline completion (#24808)
Problem: no support for custom cmdline completion
Solution: Add new vimscript functions
Add the following two functions:
- getcmdcompltype() returns custom and customlist functions
- getcompletion() supports both custom and customlist
closes: vim/vim#12228
https://github.com/vim/vim/commit/92997dda789ad8061841128cbc99b15ec0374411
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_cmdline.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index eaea31f3eb..aab65eb8fe 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -3649,4 +3649,42 @@ func Test_getcompletion_usercmd() delcom TestCompletion endfunc +func Test_custom_completion() + func CustomComplete1(lead, line, pos) + return "a\nb\nc" + endfunc + func CustomComplete2(lead, line, pos) + return ['a', 'b']->filter({ _, val -> val->stridx(a:lead) == 0 }) + endfunc + func Check_custom_completion() + call assert_equal('custom,CustomComplete1', getcmdcompltype()) + return '' + endfunc + func Check_customlist_completion() + call assert_equal('customlist,CustomComplete2', getcmdcompltype()) + return '' + endfunc + + command -nargs=1 -complete=custom,CustomComplete1 Test1 echo + command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo + + call feedkeys(":Test1 \<C-R>=Check_custom_completion()\<CR>\<Esc>", "xt") + call feedkeys(":Test2 \<C-R>=Check_customlist_completion()\<CR>\<Esc>", "xt") + + call assert_fails("call getcompletion('', 'custom')", 'E475:') + call assert_fails("call getcompletion('', 'customlist')", 'E475:') + + call assert_equal(getcompletion('', 'custom,CustomComplete1'), ['a', 'b', 'c']) + call assert_equal(getcompletion('', 'customlist,CustomComplete2'), ['a', 'b']) + call assert_equal(getcompletion('b', 'customlist,CustomComplete2'), ['b']) + + delcom Test1 + delcom Test2 + + delfunc CustomComplete1 + delfunc CustomComplete2 + delfunc Check_custom_completion + delfunc Check_customlist_completion +endfunc + " vim: shiftwidth=2 sts=2 expandtab |