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

Re: A weird bug of grep completion



> 2018/07/28 11:28, Joseph Lee <cgjosephlee@xxxxxxxxx> wrote:
> 
> A weird behavior happened when completing `grep --no-*` arguments.
> While typing `--no-group-separator`, which is a GNU only argument, after another `--no-*`, the cursor stoped in a wrong place and unable to finish completion. But it works right when `--no-group-separator` goes ahead.

The problem can be reproduced by simple examples shown below,
but I don't know how to fix it.

% compdef '_arguments : -a-a -a-b -a-c -a-d-e' cmd

Then the following work as expected
('<TAB>' can be replaced by '-<TAB>' or '-a-<TAB>' etc.)
% cmd <TAB>
% cmd -a-a <TAB>
% cmd -a-a -a-b -a-c <TAB>
% cmd -a-a -a-d-e <TAB>

But this does not work
% cmd -a-a -a-b <TAB>

So the problem occurs when
  exactly two possibilities are remaining for completion
    and
  one of the possibilities contains two (or more) hyphens
  (as in a-d-e) except for the leading '-'.

# If -a-d-e is replaced by -a-d-c then behavior changes
# (becomes worse, I think).

The problem is related with the match-spec "r:|[_-]=*" used
by _arguments (hard-coded in parse_cadef(), computil.c).
For example, the following does not work either:

% compdef 'compadd -M "r:|[_-]=*" a-a a-b-a' cmd
% cmd <TAB>

But I couldn't get exactly why this happens or how to
fix this.


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