Allow user commands to handle completion argument as a whole (add -nargs=_ command argument)#20189
Allow user commands to handle completion argument as a whole (add -nargs=_ command argument)#20189habamax wants to merge 7 commits into
Conversation
It should 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`
Relates vim#20102
to make following test pass
command! -nargs=_ -complete=arglist DoCmd :
call assert_equal("\n Name Args Address Complete Definition"
\ .. "\n DoCmd _ arglist :",
\ execute('command DoCmd'))
|
I think this is ready. |
|
If this is accepted, @dkearns could you pls handle this in vim's syntax?
|
|
I haven't thought about this enough to come up with a strong option but there's no reason that the |
The reason is current implementation -- it expects 1 char throughout the codebase for the |
|
But if Not too much of the code I guess contrary to my prev message. len arithmetic here: and parsing here Still 1 letter is simpler :) |
|
I don't have a strong opinion, all seem to be rather magic :) |
|
Let it be _ then. |
chrisbra
left a comment
There was a problem hiding this comment.
Thanks, I think we need the EX_NOSPC in the definition for the _ case, otherwise the <f-args> are not correctly parsed (see the new test suggested).
|
@chrisbra done. Failing test is unrelated to the changes. |

Problem: User commands with a single argument can't complete argument with unescaped spaces.
Solution: Add -nargs=_ command argument to not split command argument on white spaces for the completion purposes.
The difference between the
-nargs=1and-nargs=_:Completing
:MyCmd1 two va<tab>will complete with:Completing
:MyCmd2 two va<tab>will complete with:Relates