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

Re: cd /u/N/v/ tab expansion



On Sat, Apr 16, 2022 at 20:00:18 -0700, Bart Schaefer wrote:

>> > $ cd /e/s/s/[tab]
>> > No matches for: `directory'
>>
>> This happens with: setopt glob_complete interfering with
>>
>> zstyle ':completion:*' list-dirs-first true
> 
> I am not able to reproduce this with zsh-5.8.1.2-test-9-g0ad3b11, at
> least not with only:
> 
> zstyle '*' format %d
> zstyle ':completion:*' list-dirs-first true
> zstyle ':completion:*:*:*:*' list-suffixes yes
> setopt globcomplete

I might look for the other options involved if that matters, to provide
minimal config, however since you see the effect in scenario below I
guess the above one is only some compound side-effect (as this is also
fixed/masked by any of my 2 proposals, either "gs" or "-U").

>> $ mkdir -p  a/{b1,b2}/d/{e1,e2}/g
>> $ ls a/b/d/e/g[tab]
>> No matches for: `files' or `directory'
> 
> This I am able to reproduce with the settings above.
> 
> However, if I invoke _next_tags at that point, I get:
> 
> % ls a/b/d/e/g
> directory
> b1/d/e/g  b2/d/e/g
> 
> So the results have been correctly completed and added, they're just
> not in the tag group where they appear on the first attempt.

This is why "-U" alone also "fixes" my case as far as I understand (?).

> The settings of list-dirs-first and list-suffixes have no effect on
> the tag to which the matches are added in this case.  It's all down to
> globcomplete.  _next_tags works here, too.
> 
> When globcomplete is set, the following differences occur:
> _path_files line 251 forces menu=yes
> _path_files line 737 sets SUFFIX=*/d/e/g*
> _path_files returns false to _files line 119, so ret=0 is not done at line 120
> _files line 109 invokes _tags which calls comptags -N
> _files returns false to _arguments, so ret=0 is not done at line 465
> _arguments line 467 sets alwopt=yes
> _arguments line 538 test is true, so 543-551 run compadd
> _arguments line 586 is false, returns false to _dispatch, no ret=0 at line 63
> _dispatch returns false to _complete, no ret=0 at line 117
> _complete returns false _main_complete

This is far beyond my skills on completion flow tracking...

> As you mention in a later message on this this thread, one problem is
> at _path_files line 737, that suffix will never match given that the
> /e/ path segment is ambiguous.  Using :gs as you suggested resolves
> everything after that, but introduces a new difference at
> _main_compete:411, where compstate[pattern_match]='*' and
> unambiguous_cursor=8 (instead of 4 in the noglobcomplete case).  That
> seems to go along with having forced menu completion on, but it seems
> odd.

During some tests I did saw a 'weird' jumping of cursor from 'b'
position forward after a tab, just like the single disambiguation took
over and chosen both (AFAIR), but I didn't record the scenario.

> Regarding:
>> -             compadd "$tmp4[@]" $listopts - "$i"
>> +             compadd "$tmp4[@]" -U $listopts - "$i"
> 
> Try ${Uopt} instead of -U there, and see if that makes any difference?

I've already tried this without success.


> I don't seem to be able to re-create the setup for your "ctrl-g
> toggling of behaviour" incident.  Can you specify?

Sure, minimal config that exposes this "state-leaking":


setopt glob_complete

autoload -U compinit
compinit

zstyle ':completion:*' completer _complete _prefix
zstyle ':completion:*' add-space true
zstyle ':completion:*' menu select=long-list select=1
zstyle ':completion:*:*:*:*' list-suffixes yes


with _no_ "-U" added in _path_files (i.e. "-U" apparently fixes this one).
Note the 'add-space' style is optional, but enabled makes the problem
more viable ("toggleable").


With list-dirs-first working properly for "middle part ambiguosity" I
might simply disable the list-suffixes, however this is suspicious
itself to toggle results between consecutive completions.

best regards,
-- 
Tomasz Pala <gotar@xxxxxxxxxxxxx>




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