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

Re: completion autolist has time-sensitive interface



On Tue, Aug 14, 2018 at 10:49 PM,  <frederik@xxxxxxx> wrote:
> Dear Zsh Hackers,
>
> Sometimes completion is so laggy on my system that when I press TAB
> after e.g. "man perl", nothing seems to happen. So I press it again.
> Still nothing happens. Completion seems broken.
>
> What happens is that if I just press TAB once, e.g. after "man perl",
> there is a one-second delay and a prompt "zsh: do you wish to see all
> 201 possibilities (51 lines)?". At this point I can press TAB again,
> which is equivalent to "y" I guess, and I see a list of completions.

The delay is almost certainly the time required to generate the 201
possibilities rather than any "intentional" pause that zsh is doing.

Yes, at that particular prompt TAB and y/Y are equivalent, also ctrl-C
and ctrl-D (eof) and n/N are equivalent.

But there's more going on than that.  Before displaying the prompt,
zsh checks to see whether you have already typed something else
(typeahead) and if you have, it assumes you decided to disambiguate
the input further, so it skips printing the prompt and proceeds as if
you had answered "n".  So by pressing the second TAB while zsh is
still working on the set of completion for the menu, you have told the
shell you don't want to wait for the menu and it should simply
proceed.

> However, if I press TAB twice quickly in succession then I see no
> list, it is exactly as if there are no completions at all. (Actually
> if the prompt is at the bottom of the screen, I get a newline)

The faster you press the two TABs, the more likely you are to trigger
the typeahead detection.

> I find
> it confusing that the completion interface would be time-sensitive in
> this manner. Why TAB-delay-TAB would behave differently from TAB-TAB.

Back in the day, a lot of people would automatically muscle-memory
whack the tab key after typing part of a word, realize they didn't
mean to, and keep typing more of the word.  They were annoyed when the
shell ate part of their continued typing as the answer to the prompt,
leaving them with a word with one missing letter in the middle, so the
shell was changed to not do that.  This is also why pressing a second
TAB when the prompt does appear is treated as yes.



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