diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-05-18 17:44:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-18 17:44:26 +0800 |
| commit | 7b46848f140285be586cc3946db6976bd6bed2a5 (patch) | |
| tree | 3ba2b991720f4b82a09698d9e02b3b6532b1c4d0 /src/nvim/lua/executor.c | |
| parent | 3ffe29d679b2a4aee5a2f6fd9eee4845c4fef0e5 (diff) | |
| download | rneovim-7b46848f140285be586cc3946db6976bd6bed2a5.tar.gz rneovim-7b46848f140285be586cc3946db6976bd6bed2a5.tar.bz2 rneovim-7b46848f140285be586cc3946db6976bd6bed2a5.zip | |
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<string>
var all = ["qqqq", "aaaa", "qq aa"]
return all->matchfuzzy(A)
enddef
command! -nargs=_ -complete=customlist,TestComplete Test echo <q-args>
```
`:Test q a<tab>` 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 <habamax@gmail.com>
Diffstat (limited to 'src/nvim/lua/executor.c')
| -rw-r--r-- | src/nvim/lua/executor.c | 4 |
1 files changed, 3 insertions, 1 deletions
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] = '?'; |