diff options
author | Christian Clason <c.clason@uni-graz.at> | 2021-10-21 17:46:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 17:46:24 +0200 |
commit | eaa03b7181ff0e0cca7aef263206035c66e34302 (patch) | |
tree | f37629073f2bd2bf5bc57f6c7766f95b8d710beb | |
parent | d0f10a7addc17149d7e63ff20705762c357eb469 (diff) | |
download | rneovim-eaa03b7181ff0e0cca7aef263206035c66e34302.tar.gz rneovim-eaa03b7181ff0e0cca7aef263206035c66e34302.tar.bz2 rneovim-eaa03b7181ff0e0cca7aef263206035c66e34302.zip |
vim-patch:8.2.3550: completion() does not work properly (#16112)
* vim-patch:8.2.3550: completion() does not work properly
Problem: completion() does not work properly.
Solution: Set xp_line and add WILD_HOME_REPLACE. (Shougo Matsushita,
closes vim/vim#9016)
https://github.com/vim/vim/commit/ae38a9db7770b38889fbf06908cc69d42b463a73
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 946bde060d..1c78e25639 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -3359,7 +3359,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) expand_T xpc; bool filtered = false; int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH - | WILD_NO_BEEP; + | WILD_NO_BEEP | WILD_HOME_REPLACE; if (argvars[1].v_type != VAR_STRING) { EMSG2(_(e_invarg2), "type must be a string"); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 4524026e3f..68dd4a22ff 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2915,6 +2915,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) ExpandInit(xp); xp->xp_pattern = (char_u *)buff; + xp->xp_line = (char_u *)buff; xp->xp_context = EXPAND_COMMANDS; // Default until we get past command ea.argt = 0; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index ffca415282..98340d0ac6 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -309,6 +309,11 @@ func Test_getcompletion() let l = getcompletion('NoMatch', 'dir') call assert_equal([], l) + if glob('~/*') !=# '' + let l = getcompletion('~/', 'dir') + call assert_true(l[0][0] ==# '~') + endif + let l = getcompletion('exe', 'expression') call assert_true(index(l, 'executable(') >= 0) let l = getcompletion('kill', 'expression') @@ -422,6 +427,16 @@ func Test_getcompletion() let l = getcompletion('call paint', 'cmdline') call assert_equal([], l) + func T(a, c, p) + return "oneA\noneB\noneC" + endfunc + command -nargs=1 -complete=custom,T MyCmd + let l = getcompletion('MyCmd ', 'cmdline') + call assert_equal(['oneA', 'oneB', 'oneC'], l) + + delcommand MyCmd + delfunc T + " For others test if the name is recognized. let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user'] if has('cmdline_hist') |