From bd4b45dd1b0b0e6afdef5a30c565dadd58bb505a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Aug 2025 21:38:48 +0800 Subject: [PATCH] vim-patch:9.1.1608: No command-line completion for :unsilent {command} Problem: No command-line completion for :unsilent {command}. Solution: Add missing command arg completion (Doug Kearns). (author) Add completion tests for all command modifiers. closes: vim/vim#17524 https://github.com/vim/vim/commit/126731c8fde545e8aedb83076badbc8a6ef1201d Co-authored-by: Doug Kearns (cherry picked from commit fe42c81f2e078a7fef8fc1ce639f9005e016298f) --- src/nvim/cmdexpand.c | 1 + test/old/testdir/test_cmdmods.vim | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 9abfc68b00..50665740d7 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1887,6 +1887,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa case CMD_tab: case CMD_tabdo: case CMD_topleft: + case CMD_unsilent: case CMD_verbose: case CMD_vertical: case CMD_windo: diff --git a/test/old/testdir/test_cmdmods.vim b/test/old/testdir/test_cmdmods.vim index 91a396b0e1..c4ad5c6094 100644 --- a/test/old/testdir/test_cmdmods.vim +++ b/test/old/testdir/test_cmdmods.vim @@ -1,5 +1,23 @@ " Test for all command modifiers in +let s:luaeval_cmdmods =<< trim END + vim.iter(loadfile('../../../src/nvim/ex_cmds.lua')()):map(function(cmd) + if cmd.func == 'ex_wrongmodifier' or cmd.command == 'hide' then + return cmd.command + else + return nil + end + end):totable() +END +let s:cmdmods = [] + +func s:get_cmdmods() + if empty(s:cmdmods) + let s:cmdmods = luaeval(s:luaeval_cmdmods->join("\n")) + endif + return s:cmdmods +endfunc + func Test_keep_cmdmods_names() call assert_equal('k', fullcommand(':k')) call assert_equal('k', fullcommand(':ke')) @@ -29,10 +47,13 @@ func Test_keep_cmdmods_names() endfunc func Test_cmdmod_completion() - call assert_equal('edit', getcompletion('keepalt ed', 'cmdline')[0]) - call assert_equal('edit', getcompletion('keepjumps ed', 'cmdline')[0]) - call assert_equal('edit', getcompletion('keepmarks ed', 'cmdline')[0]) - call assert_equal('edit', getcompletion('keeppatterns ed', 'cmdline')[0]) + for mod in s:get_cmdmods() + let cmd = $'{mod} ed' + if mod == 'filter' + let cmd = $'{mod} /pattern/ ed' + endif + call assert_equal('edit', getcompletion(cmd, 'cmdline')[0]) + endfor endfunc " vim: shiftwidth=2 sts=2 expandtab