Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: completion within a function



On Sat, Jan 2, 2021 at 9:31 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Jan 2, 2021 at 6:47 PM Felipe Contreras
> <felipe.contreras@xxxxxxxxx> wrote:
> >
> > OK. That works. Takes 8.7s to complete on the Linux repository with
> > 3350 entries on my system, but it does complete.
>
> That's likely because it's doing "compinit -D".  It would go faster
> for subsequent tests if they all ran in the same shell with that
> pre-loaded.

At the moment I can't do that, it has to be a new shell every time,
and your version seems to take longer to load, slowing the tests.

> > You do see why I think 'git checkout ' is more friendly than 'git'
> > 'checkout' '', right?
>
> For your usage, I do, but that makes it a bit harder to separate the
> context from the completions.

OK. But it still doesn't work correctly: I can't pass empty arguments
in the middle of a command-line.

For example in the tests I added a fake "func" command that calls a
function, for example:

  git func __gitcomp_opts "octopus ours recursive resolve subtree" ""
"re" --strategy=re

Why my method that works fine, with your method what effectively ends
up happening is the equivalent of:

  git func __gitcomp_opts "octopus ours recursive resolve subtree"
"re" --strategy=re

The "" is there in the array, I don't know why varead seems to ignore it.

Also, I don't understand why is there an argv there:

  vared -M __complete -i __init_complete ${${argv:+argv}:-reply}
  (( ARGC )) || print -nrl -- "~~~${(@)reply}~~~"

Isn't "reply" always used? And ARGC is always 0?

Cheers.

-- 
Felipe Contreras




Messages sorted by: Reverse Date, Date, Thread, Author