From 7b46848f140285be586cc3946db6976bd6bed2a5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 18 May 2026 17:44:26 +0800 Subject: vim-patch:9.2.0494: User commands cannot handle single args with spaces (#39854) Problem: User commands cannot handle single args with spaces Solution: Add the -nargs=_ attribute (Maxim Kim) -nargs=_ allow user commands to have a single argument with spaces. For example given the following Test command and TestComplete function: ``` vim9script def TestComplete(A: string, _: string, _: number): list var all = ["qqqq", "aaaa", "qq aa"] return all->matchfuzzy(A) enddef command! -nargs=_ -complete=customlist,TestComplete Test echo ``` `:Test q a` should successfully complete `qq aa` fixes: vim/vim#20102 closes: vim/vim#20189 https://github.com/vim/vim/commit/f0e874a129a702457a383017b576eef1553f95d8 Co-authored-by: Maxim Kim --- src/nvim/lua/executor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index b785ed0c64..b6847f0492 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -2395,7 +2395,9 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview) char nargs[2]; if (cmd->uc_argt & EX_EXTRA) { if (cmd->uc_argt & EX_NOSPC) { - if (cmd->uc_argt & EX_NEEDARG) { + if (cmd->uc_argt & EX_ARGSPACE) { + nargs[0] = '_'; + } else if (cmd->uc_argt & EX_NEEDARG) { nargs[0] = '1'; } else { nargs[0] = '?'; -- cgit