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

Re: [Bug] Doubled completions with suffix aliases and grouping

On Mon, Jul 06, 2020 at 09:51:06PM -0700, Bart Schaefer wrote:
> On Sun, Jul 5, 2020 at 12:24 PM Guido Cella <guidocella91@xxxxxxxxx> wrote:
> >
> > I think that the bug is adding files that aren't executable to the
> > "executable file" grouping.
> Aye, well, that's not exactly a bug either.  The position taken when
> developing the completion code was that it's always better to offer
> something that the user might possibly mean rather than to offer
> nothing; i.e., err on the side of too much information rather than too
> little.  Because _command_names uses _alternative, the two branches
> (executables and suffix-aliases) don't "know" that the other might
> produce overlapping matches, so each generates its result
> independently, and when executables finds nothing, it falls back to
> all files.
> There are two elements of your specific example that could potentially
> be considered bugs.  The first is that there's no file-patterns zstyle
> for the "executables" tag; the closest you can get is to set one for
> the :completion:complete:-command-:: context.  The second is that this
> doesn't work:
> zstyle :completion::complete:-command-::executables ignored-patterns '*(^*)'
> Instead you have to do this:
> zstyle :completion::complete:-command-::executables ignored-patterns '*(#q^*)'
> However, I think you'll find if you do that latter, you'll get what you want.
I agree that it's better to complete all files rather than to offer
nothing, my problem is that it completes all files again even when
suffix aliases do offer matches.

zstyle :completion::complete:-command-::executables ignored-patterns '*(#q^*)'
is worse since it stops completing directories (and real executables)
when there's matching suffix alias. :/

mkdir {1..9}
touch foo.txt

Only foo.txt is completed.

Anyway, by navigating the completion code I could guess fixing this
would require changing the code too much because executables and suffix
aliases are completed from different places. I only enabled grouping so
I could set list-dirs-first and have suffix aliases for everything, so
it's annoying to get double completions, even of many files, each time I
browse a leaf directory.

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