diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-14 06:47:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-14 06:47:32 +0800 |
commit | fbc644ba3114ffc054d52789c9d03288d7d4b9bb (patch) | |
tree | 66cd21d9fd36d0f9c9a7d799e14a901236fae54b | |
parent | 06bce8bf5c3b6a2753778461426212c61e9f2036 (diff) | |
download | rneovim-fbc644ba3114ffc054d52789c9d03288d7d4b9bb.tar.gz rneovim-fbc644ba3114ffc054d52789c9d03288d7d4b9bb.tar.bz2 rneovim-fbc644ba3114ffc054d52789c9d03288d7d4b9bb.zip |
vim-patch:9.0.1708: getcompletion() failes for user-defined commands (#24707)
Problem: getcompletion() failes for user-defined commands
Solution: set context for completion function
closes: vim/vim#12681
closes: vim/vim#12680
https://github.com/vim/vim/commit/8ef1fbc0c3ca8dca32c352f3cf30e7a4b3096a94
Co-authored-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/nvim/usercmd.c | 3 | ||||
-rw-r--r-- | test/old/testdir/test_cmdline.vim | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 65720342ce..b9d4308b99 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -296,6 +296,9 @@ const char *set_context_in_user_cmdarg(const char *cmd FUNC_ATTR_UNUSED, const c return set_context_in_menu_cmd(xp, cmd, (char *)arg, forceit); } if (context == EXPAND_COMMANDS) { + if (xp->xp_context == EXPAND_NOTHING) { + xp->xp_context = context; + } return arg; } if (context == EXPAND_MAPPINGS) { diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 58d37b5da7..506b3d41ff 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -3636,4 +3636,14 @@ func Test_rulerformat_position() call StopVimInTerminal(buf) endfunc +func Test_usercmd_completion() + let g:complete=[] + command! -nargs=* -complete=command TestCompletion echo <q-args> + let g:complete = getcompletion('TestCompletion ', 'cmdline') + let a = getcompletion('', 'cmdline') + + call assert_equal(a, g:complete) + delcom TestCompletion + unlet! g:complete +endfunc " vim: shiftwidth=2 sts=2 expandtab |