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

126731c8fd

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
(cherry picked from commit fe42c81f2e)
This commit is contained in:
zeertzjq
2025-08-08 21:38:48 +08:00
committed by github-actions[bot]
parent 6c2f06b537
commit bd4b45dd1b
2 changed files with 26 additions and 4 deletions

View File

@@ -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:

View File

@@ -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