Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cd /u/N/v/ tab expansion
On Sun, Apr 10, 2022 at 16:32:22 +0200, Tomasz Pala wrote:
> This happens with: setopt glob_complete interfering with
[...]
> $ mkdir -p usr/{share/{aclocal,atever},sbin,src}
> $ touch usr/sbin/a1 usr/share/a1 usr/share/a2
>
> $ ls u/s*/a[tab]
[...]
>
> My solution was to use:
>
> zstyle ':completion:*:*:*:*' list-suffixes yes
>
> but then:
>
> $ mkdir -p a/{b1,b2}/d/{e1,e2}/g
> $ ls a/b/d/e/g[tab]
> No matches for: `files' or `directory'
I've tracked down this problem down to the initial commit:
https://sourceforge.net/p/zsh/code/ci/e0dc80e0e54df85329b1644001df80e908fd5b9c/
around line 745 of _path_files (currently), there is this code:
if [[ -z "$listsfx" ]]; then
[...]
else
[[ -n "$compstate[pattern_match]" ]] && SUFFIX="${SUFFIX:s./.*/}*"
this SUFFIX manglignt is required for:
$ ls u/s*/a[tab] changes "/a" to "*/a*"
but it breaks
$ ls a/b/d/e/g[tab] changing "/d/e/g" to "*/d/e/g*"
In both cases all the files ARE compadded properly, the problem emerges
from the leading and trailing asterisks added to the SUFFIX.
1. why the "*/d/e/g*" SUFFIX prevents completions from being used?
2. should it be left intact? What makes this *required* for u/s*/a?
3. if to be left intact - how to prevent this from happening? The only
difference I see are MATCH=/ MBEGIN=6 MEND=6.
The solution I've came works for me, but I got no idea why and if that's
even the rational way:
- [[ -n "$compstate[pattern_match]" ]] && SUFFIX="${SUFFIX:s./.*/}*"
+ [[ -n "$compstate[pattern_match]" ]] && [ -z "$MATCH" ] && SUFFIX="${SUFFIX:s./.*/}*"
This code is full of hackery... "pws non-canonical hack", "A little
extra hack", "it should now be smart"...
--
Tomasz Pala <gotar@xxxxxxxxxxxxx>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author