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

Re: Setting state in _arguments



=?ISO-8859-1?Q?Jesper_Nyg=E5rds?= wrote:
> On the command line, I write: "myfoo --<tab>", and the completion kicks in
> and gives me the options "--option1" and "--option2", which is what I
> expected. However, on /dev/pty2 I see "state: subcommand", which I did NOT
> expect. I would have thought that since only "--option1" or "--option2"
> could possibly match after "--", state would not have been set*, *but it is.

_arguments has no way of knowing that subcommands can't begin with "--"
so while it adds the completion matches for the options, it also
considers the *:... rule to be applicable.

> The trouble with this is that in the gradle completion, the possible
> subcommands are generated inside the if statement in this case, and thatis
> time consuming. I would thus like to avoid going into it when the "--" on
> the command line indicates that an option should be completed.

You can perform some explicit tests before starting the time consuming
operation, perhaps test whether the current word starts with "--".

Oliver



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