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

Re: menu-select doesn't respect COMPLETE_IN_WORD option



On Sat, Jun 13, 2020 at 9:28 PM Alan <8fvebtoeq87@xxxxxxxxx> wrote:
>
> When I leave completeinword unset, _prefix completion simply doesn't work, even if I have:
>
> zstyle ':completion:*' completer _expand _prefix _complete _ignored _prefix
>
> One additional thing I've found to be really strange about _prefix completion is if there is only one possible match. For example:
>
> % ls -a
> ./  ../
> % mkdir -p dir1/dir2/dir3
> % ls dir1/di_r2/dir3<menu-complete>   (<-- where _ is the position of the cursor)
> % ls dir1_   (<-- the "/dir2/dir3" part of the line has been removed!)

Starting from "zsh -f" and like you using "_" for cursor position:

% compinit -D
% zstyle \* format %d
% zstyle ':completion:*' menu 'select=1'
% zstyle ':completion:*' completer _expand _prefix _complete _ignored
% mkdir -p dir1/dir2/dir3
% ls dir1/di_r2/dir3
% ls dir1/dir2/dir3/_

The above happens with any of complete-word, expand-or-complete, or
menu-complete.

If I run expand-or-complete-prefix instead:

% ls dir1/di_r2/dir3
% ls dir1/dir2/_r2/dir3

Which looks exactly like I would expect.

% set -o | grep complete
completealiases       off
completeinword        off
globcomplete          off
menucomplete          off

If I turn on "globcomplete" then nothing works except
expand-or-complete-prefix, but I still don't get anything removed from
the line.  I just get a beep and the cursor stays in the middle of
"dir2" and the description "files" appears (from the format zstyle).

If I turn on "completeinword" then I can reproduce your described
behavior with menu-complete, although expand-or-complete-prefix still
works as expected.  Looking at the output of ^x? (complete-debug),
what's happening is that _prefix says "if there is only one possible
completion, then insert only the unambiguous prefix" which (because of
the way completing across a directory boundary works) is only "dir1".
This does not occur if you are completing a file name in the current
directory:

% touch part1.part2.part3
% ls part1.pa_rt2.part3
% ls part1.part2.part3_rt2.part3

So I still think you want to leave complete-in-word turned off and
find out what other part of your startup is breaking things when you
do.

Incidentally the _prefix behavior with the unambiguous prefix is
itself a compromise; before workers/18841 (2003-07-09) it would
alarmingly delete the entire word from the line.



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