Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"zsh: do you wish to see all X possibilities" #311

Closed
Timoses opened this issue Jul 28, 2021 · 26 comments
Closed

"zsh: do you wish to see all X possibilities" #311

Timoses opened this issue Jul 28, 2021 · 26 comments
Labels
bug Something isn't working

Comments

@Timoses
Copy link

Timoses commented Jul 28, 2021

  • zsh-autocomplete version: 3abe9db
  • Zsh version: /bin/zsh zsh-5.8-0-g77d203f
  • Framework: none
  • Plugin manager: antibody
  • Operating system: Linux (Fedora 33)
  1. Paste the following into your terminal and press Enter:
    cd $(mktemp -d)
    git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
    print 'PS1="%# " PS2="  " RPS2="< %^"; setopt transientrprompt
    source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
    ' > .zshrc
    SHELL==zsh
    exec -c zsh -fc "HOME=$PWD SHELL=$SHELL TERM=$TERM exec $SHELL -d"
  2. Once you're able to reproduce your problem in the shell session created
    above, copy-paste the contents of your terminal here:
    8:26:32 0> cd $(mktemp -d)
8:26:37 0> git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
Cloning into 'zsh-autocomplete'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 59 (delta 1), reused 27 (delta 1), pack-reused 0
Receiving objects: 100% (59/59), 1.64 MiB | 5.59 MiB/s, done.
Resolving deltas: 100% (1/1), done.
8:26:54 0> print 'PS1="%# " PS2="  " RPS2="< %^"; setopt transientrprompt
    source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
    ' > .zshrc
8:27:00 0> SHELL==zsh
8:27:04 0> exec -c zsh -fc "HOME=$PWD SHELL=$SHELL TERM=$TERM exec $SHELL -d"
% ls /tmp/d
directory
ansible/                                                                         nvimFRj7hk/                                                                        nvimGIiDhQ/
nvimHVeGPf/                                                                      nvimM6kVJS/                                                                        nvimMIY0Qv/
nvimSNMXCI/                                                                      nvimhZRA8u/                                                                        nvimmuWVBt/
nvimqrkVgV/                                                                      nvimrS4lVd/                                                                        nvimuQDh64/
ssh-FXl7FdjZTPqQ/                                                                ssh-QpIdXWmlrdjl/                                                                  ssh-dlBSaYiT9mVa/
ssh-fP66a5D7ffgG/                                                                ssh-lqM0l7isObml/                                                                  ssh-xkTkw8jAqGdL/
systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-ModemManager.service-fBO09f/    systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-chronyd.service-4KsXch/           systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-colord.service-nRwUGi/
systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-dbus-broker.service-p7gaSf/     systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-earlyoom.service-YlfYUg/          systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-low-memory-monitor.service-HcDAFg/
systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-rtkit-daemon.service-5oDZQh/    systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-spice-vdagentd.service-Fn9krf/    systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-switcheroo-control.service-HK2mKg/
systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-systemd-logind.service-BwhHXg/  systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-systemd-resolved.service-vsffeh/  systemd-private-fa6d3e80cbe04b1dba57d834d461ed91-upower.service-NiXlXg/
tmp.0m6JINAKLI/                                                                  tmp.1sIB3E454B/                                                                    tmp.3DKXaMquuG/
tmp.4mwDIFIKcm/                                                                  tmp.4nXgMNXDgc/                                                                    tmp.5dyLADK1TM/
tmp.5xMFbJynZe/                                                                  tmp.6BlUbUuFwu/                                                                    tmp.6ulwuEY86X/
tmp.79BeBvZLUE/                                                                  tmp.7X8OndMyCZ/                                                                    tmp.7voN5jL3wK/
tmp.8P7IqEBUER/                                                                  tmp.8ULNnJNwdK/                                                                    tmp.8iQz5eS5MS/
tmp.AOVl17cWuu/                                                                  tmp.C2ltK9UCPA/                                                                    tmp.Ckx4CFYK7s/
tmp.Fh4DC1Awmj/                                                                  tmp.GhHjwEYgmc/                                                                    tmp.JqLbFVbobJ/
tmp.MUmPgVXxm9/                                                                  tmp.NNBaE0nwWs/                                                                    tmp.NObZTnD2CT/
tmp.OJdoGAd0ET/                                                                  tmp.OnUne46Wkc/                                                                    tmp.P2bsWX3n9r/
tmp.PnYMVxbtBK/                                                                  tmp.QFRLI95iEw/                                                                    tmp.QqNHg5RFTj/
tmp.R5RVFC4Dr0/                                                                  tmp.SGcAWfhvth/                                                                    tmp.Ssi8CSJesW/
tmp.TG5xOWFgLi/                                                                  tmp.TQRtiPOy9n/                                                                    tmp.TgMmy9Ooax/
tmp.Vgl43TZQ6o/                                                                  tmp.XvUVqWlGbT/                                                                    tmp.Yr74Xp2hUX/
tmp.ZReNWOQSas/                                                                  tmp.a0lMGf5Fg2/                                                                    tmp.aoOzvhkYUG/
tmp.b9veaomYVf/                                                                  tmp.c4Y5PmV2J5/                                                                    tmp.cxH2BupMyV/
tmp.dyvsLrLa0i/                                                                  tmp.eXKGrd5hqe/                                                                    tmp.fQ5SfSh1yV/
tmp.gMWXBzenV2/                                                                  tmp.gNagVwGsyb/                                                                    tmp.ged1Jgv1Dv/
tmp.goba9PhANj/                                                                  tmp.hYuLjLi72b/                                                                    tmp.hqpCU4Vc8c/
tmp.iXSGwej1il/                                                                  tmp.ieeiw3RBLf/                                                                    tmp.ijwJ9QsonP/
tmp.kiSGrXYLxm/                                                                  tmp.kkyqRLPzJt/                                                                    tmp.lHupNWenOO/
tmp.lXu0sr22Wh/                                                                  tmp.lpGUOp7L7S/                                                                    tmp.lpPZ4Bn5bf/
tmp.no4uMxXXaN/                                                                  tmp.oSfNM8Y8tC/                                                                    tmp.oceP2bXRwt/
tmp.oligt0pzSS/                                                                  tmp.onr6GYChqQ/                                                                    tmp.q7bJVnNRQq/
tmp.qdWvy0BhOT/                                                                  tmp.qfoV6668ls/                                                                    tmp.qy3Ot04Oyw/
tmp.rVm7vte1yc/                                                                  tmp.rnpX61vu2C/                                                                    tmp.sGTuHtm2YY/
tmp.sdflTmTEEO/                                                                  tmp.uSB5Rpt9iV/                                                                    tmp.vS5oRPOIRg/
tmp.vwVedjlPdm/                                                                  tmp.xpNqQcXPAY/                                                                    tmux-1000/
files
README.md                          fsh-dbg                            mkdp-nvim.log                      overview                           overview.json                      reply                              tmp-kmj.xpi
tmp.G1TOhM52IH                     tmp.LHDNi1D7KN
all matches
ansible nvimFRj7hk nvimGIiDhQ nvimHVeGPf nvimM6kVJS nvimMIY0Qv nvimSNMXCI nvimhZRA8u nvimmuWVBt nvimqrkVgV nvimrS4lVd nvimuQDh64 ssh-FXl7FdjZTPqQ ssh-QpIdXWmlrdjl ssh-dlBSaYiT9mVa ssh-fP66a5D7ffgG ssh-lqM0l7isObml ssh-xkTkw8jAqGdL systemd-private-fa6...

Above works when pane is zoomed in (fills space of screen).
However, once the pane is smaller I get this:

% ls /tmp/d
zsh: do you wish to see all 163 possibilities (132 lines)?

Size info when it works:

% tput cols
254
% tput lines
77

Size info when it fials:

% tput cols
127
% tput lines
38
@Timoses Timoses added the bug Something isn't working label Jul 28, 2021
@Timoses
Copy link
Author

Timoses commented Jul 28, 2021

It seems like /tmp/d* does not exist:

% ls /tmp/d*
zsh: no matches found: /tmp/d*

@marlonrichert
Copy link
Owner

Above works when pane is zoomed in (fills space of screen).
However, once the pane is smaller I get this:

I'm not sure what you mean by this. Can you please include clear, step-by-step instructions to reproduce?

@marlonrichert
Copy link
Owner

@Timoses Is this by any chance a duplicate of #291?

@marlonrichert marlonrichert added question Further information is requested and removed bug Something isn't working labels Jul 28, 2021
@Timoses
Copy link
Author

Timoses commented Jul 29, 2021

Possibly. It's at least the same symptom.

@Timoses
Copy link
Author

Timoses commented Jul 29, 2021

I'm not sure what you mean by this. Can you please include clear, step-by-step instructions to reproduce?

I am able to reproduce it on my Mac, however not with the same command (ls /tmp/d).

Step by step:

  1. Expand terminal to be "large". For the following I now get:
    % tput cols && tput lines 
    179
    56
    
  2. Try the command (on Mac I found this one working tput )
    % tput
    terminal capabilities
    OTMT   OTNL   OTbs   OTnc   OTns   OTpt  OTxr  acsc  am     bce       bel    blink  bold   bw    cbt   ccc    chts   civis  clear  cnorm  colors  cols   cpix   cr     crxm   csr
    cub    cub1   cud    cud1   cuf    cuf1  cup   cuu   cuu1   cvvis     da     daisy  db     dch   dch1  dim    dl     dl1    ech    ed     el      el1    eo     eslok  flash  gn
    hc     hls    home   hpa    hs     ht    hts   hz    ich    il        il1    in     ind    indn  init  initc  invis  is2    it     kDC    kEND    kHOM   kIC    kLFT   kNXT   kPRV
    kRIT   ka1    ka3    kb2    kbs    kc1   kc3   kcbt  kcub1  kcud1     kcuf1  kcuu1  kdch1  kend  kent  kf1    kf10   kf11   kf12   kf13   kf14    kf15   kf16   kf17   kf18   kf19
    kf2    kf20   kf21   kf22   kf23   kf24  kf25  kf26  kf27   kf28      kf29   kf3    kf30   kf31  kf32  kf33   kf34   kf35   kf36   kf37   kf38    kf39   kf4    kf40   kf41   kf42
    kf43   kf44   kf45   kf46   kf47   kf48  kf49  kf5   kf50   kf51      kf52   kf53   kf54   kf55  kf56  kf57   kf58   kf59   kf6    kf60   kf61    kf62   kf63   kf7    kf8    kf9
    khome  kich1  kind   km     kmous  knp   kpp   kri   lines  longname  lpix   mc0    mc4    mc5   mc5i  meml   memu   mgc    mir    msgr   ndscr   npc    nrrmc  nxon   oc     op
    os     pairs  rc     rep    reset  rev   ri    rin   ritm   rmacs     rmam   rmcup  rmir   rmkx  rmm   rmso   rmul   rs1    rs2    sam    sc      setab  setaf  sgr    sgr0   sitm
    smacs  smam   smcup  smglr  smir   smkx  smm   smso  smul   tbc       u6     u7     u8     u9    ul    vpa    xenl   xhp    xhpa   xon    xsb     xt     xvpa
    
  3. Now shrink the terminal window to very small. For the command from step 1. I now get
    % tput cols && tput lines
    20
    5
    
  4. Try again to type "tput " (like in step 2.):
    % tput 
    zsh: do you wish to see all 4 possibilities (5 lines)? 
    

What I found I can do even is the following:

  1. Have terminal window large
  2. Type "tput " (it will display the suggestions like in step 2. above)
  3. Shrink terminal window very small (the suggestions disappear, seemingly only blank lines are shown)
  4. Enlarge it again (it will now display like in step 4. above).

Screenshots for above:
2.
image
3.
image
4. (here you see the successful expansion from completion suggestions above, but below seems to be a new line appearing which also contains the '% tput ' line followed by 'zsh: do you wish to see all [...]'. It's very odd : P).
image

@Timoses
Copy link
Author

Timoses commented Jul 29, 2021

Above (for MacOS) I can reproduce with both native MacOS terminal.app application and alacritty terminal.

@marlonrichert
Copy link
Owner

Ah, now I get it. That's expected behavior and a "feature" of zsh. There's not really anything I can do about that. You might want to file a bug report about this on the zsh mailing lists.

@marlonrichert marlonrichert added wontfix This will not be worked on and removed question Further information is requested labels Jul 29, 2021
@Timoses
Copy link
Author

Timoses commented Jul 30, 2021

Thanks. Was able to fix it with

zstyle ':completion:*' list-prompt   ''

(https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Standard-Styles)

@Timoses
Copy link
Author

Timoses commented Jul 30, 2021

Hm, though it doesn't really fix it as it's still 'eating' key strokes...

@marlonrichert
Copy link
Owner

@Timoses But it happens only when you resize and your currently have a list of completions open, right? That case is pretty much beyond my control.

@Timoses
Copy link
Author

Timoses commented Aug 1, 2021

No, it also happens when the window is already small.
I was hoping for something like a style that says 'Only show max X lines of completions suggestions and never show "do you want to see..."'.
Didn't find anything that could help. I agree, it's on zsh side.

@marlonrichert
Copy link
Owner

No, it also happens when the window is already small.

How small?

@Timoses
Copy link
Author

Timoses commented Aug 1, 2021

Just made a 'border' test to see how small I have to shrink it so that it asks me if I want to see all (instead of just showing).

On Macos with the tput this still works:

21:42:35 130 libellem.local> tput lines && tput cols
22
77

while this shows the question whether I want to see it all (practically disturbing my typing):

21:44:09 130 libellem.local> tput lines && tput cols
22
76

Keeping the same columns and increasing the height of the window it again works (shows all completions) when the window is this large:

21:45:06 130 libellem.local> tput lines && tput cols
24
76

This is how the last scenario looks when it just barely shows:
image

@marlonrichert
Copy link
Owner

marlonrichert commented Aug 2, 2021

while this shows the question whether I want to see it all (practically disturbing my typing):

21:44:09 130 libellem.local> tput lines && tput cols
22
76

I'm unable to reproduce it when typing in a Terminal of that size on macOS. Can you give me some examples of what you're typing when you get interrupted?

@marlonrichert
Copy link
Owner

Oh, and have you updated zsh-autocomplete to the latest commit on the main branch?

@Timoses
Copy link
Author

Timoses commented Aug 2, 2021

> antibody update
marlonrichert/zsh-autocomplete a7f69c9 -> 20b332c

Well, as stated above I am typing the following: tput (<- with a space at the end).

Which by default produces this output

% tput
terminal capabilities
OTMT    OTNL   OTbs   OTnc   OTns   OTpt   OTxr      acsc   am     bce
bel     blink  bold   bw     cbt    ccc    chts      civis  clear  cnorm
colors  cols   cpix   cr     crxm   csr    cub       cub1   cud    cud1
cuf     cuf1   cup    cuu    cuu1   cvvis  da        daisy  db     dch
dch1    dim    dl     dl1    ed     el     el1       enacs  eo     eslok
flash   gn     hc     hls    home   hpa    hs        ht     hts    hz 
ich     il     il1    in     ind    indn   init      is2    it     kbs
kcbt    kcub1  kcud1  kcuf1  kcuu1  kdch1  kend      kf1    kf10   kf11
kf12    kf2    kf3    kf4    kf5    kf6    kf7       kf8    kf9    khome
kich1   km     kmous  knp    kpp    lines  longname  lpix   mc5i   mir
msgr    ndscr  nel    npc    nrrmc  nxon   op        os     pairs  rc 
reset   rev    ri     rin    rmacs  rmcup  rmir      rmkx   rmso   rmul
rs2     sam    sc     setab  setaf  sgr    sgr0      smacs  smcup  smir
smkx    smso   smul   tbc    ul     vpa    xenl      xhp    xhpa   xon
xsb     xt     xvpa                                       

If I make the window smaller it shows:

% tput 
% 
% tput 
zsh: do you wish to see all 116 possibilities (15 lines)? 








I now also found a scenario where it shows this:

% tput
terminal capabilities
OTMT   OTNL    OTbs   OTnc   OTns      OTpt   OTxr   am     bce
bel    blink   bold   bw     cbt       ccc    chts   civis  clear
cnorm  colors  cols   cpix   cr        crxm   csr    cub    cub1
cud    cud1    cuf    cuf1   cup       cuu    cuu1   cvvis  da 
daisy  db      dch    dch1   dim       dl     dl1    ed     el 
eo     eslok   flash  gn     hc        hls    home   hpa    hs 
hz     ich     il     il1    in        indn   init   is2    it 
kbs    kcub1   kcud1  kcuf1  kcuu1     kdch1  kf1    kf10   kf2
kf3    kf4     kf5    kf6    kf7       kf8    kf9    khome  kich1
km     knp     kpp    lines  longname  lpix   mc5i   mir    msgr
ndscr  nel     npc    nrrmc  nxon      os     pairs  rc     reset
rev    rin     rmacs  rmcup  rmir      rmkx   rmso   rmul   rs2
sam    sgr0    smacs  smcup  smir      smkx   smso   smul   tbc
ul     xenl    xhp    xhpa   xon       xsb    xt     xvpa      
(MORE)

(terminal screen is between the small size when it triggers "do you wish to see all ..." and the large size when it has no difficulties showing all).
This would be idea for even smaller cases that it would simply show "MORE" and not ask whether one wants to see it all.

So for reproduction it's probably best to first check on a large screen whether tput also displays lots of answers for you. If so, reduce terminal size to a very small window.

You can see it in live action here: https://asciinema.org/a/P7kHOrAKM5lhLtA5b9tMLnjNo
(Unfortunately you can't see screen resizes there, but I always put tput lines && tput cols after a terminal size change).

@marlonrichert
Copy link
Owner

If I make the window smaller it shows:

Yes, that was my point. It only shows under the following conditions, right?

  1. Generate a large completion list (with or without zsh-autocomplete).
  2. Make the window small enough that the list no longer fits.
  3. Now you get the do you wish to see message, which eats up a key stroke.

Is that what you mean? If so, then no, there's nothing I can do about that, as the resizing does not trigger zsh-autocomplete and is handled by zsh internally. This behavior also happens without zsh-autocomplete.

But the following never happens, right?

  1. Type something with zsh-autocomplete enabled.
  2. Suddenly get the do you wish to see message, eating up a random key stroke.

That should never happen (except for a couple of cases that trigger bugs in zsh's completion code).

@marlonrichert
Copy link
Owner

marlonrichert commented Aug 2, 2021

This would be idea for even smaller cases that it would simply show "MORE" and not ask whether one wants to see it all.

zsh-autocomplete attempts to always show (MORE) and nothing else, when the completion list doesn't fit on screen. However, as I pointed out above, when you resize your terminal window with a completion list open, zsh does not send any events about this to zsh-autocomplete (and thus it doesn't get any chance to redraw the screen), but instead handles it internally.

@Timoses
Copy link
Author

Timoses commented Aug 4, 2021

But the following never happens, right?

1. Type something with `zsh-autocomplete` enabled.

2. Suddenly get the `do you wish to see` message, eating up a random key stroke.

That should never happen (except for a couple of cases that trigger bugs in zsh's completion code).

It does. As explained above, when the terminal is small enough that the completion menu entries do not fit then it displays 'do you wish ...'.

It happens either by resizing while the completion menu shows or by already having a small terminal size and then typing tput which should show completion menu but it shows '**do you wish to ...*'.

@Timoses
Copy link
Author

Timoses commented Aug 4, 2021

Watch it here: https://vimeo.com/583025620

@marlonrichert
Copy link
Owner

Thanks for the video. I will add a minimum required terminal size to the Readme, as there really isn’t much I can do for that case. 🙂

@Timoses
Copy link
Author

Timoses commented Aug 4, 2021

I admit the terminal from above window is very small : D.

This would be a more practical example where it's really annoying and where the size isn't really that small:
https://vimeo.com/583029610

Plus, it seem's there are some weird effects where first it works with 'MORE' but then again not. And it prints 'do you wish ...' when typing only t at a quite large size as well.

EDIT: I'll reupload the video, seems to be wrong..

@Timoses
Copy link
Author

Timoses commented Aug 4, 2021

Fixed link: https://vimeo.com/583029610 (above was broken)

@Timoses
Copy link
Author

Timoses commented Aug 4, 2021

From above recording I can reproduce the follwing:

  • Have terminal/pane a certain size
  • Write t
  • -> It displays suggestions with 'MORE' at the end
  • Reduce height of terminal
  • Write t
  • -> It displays 'do you wish...'
  • Increase size again to previous size
  • Write t
  • -> It displays 'do you wish...' (I would expect it to write 'MORE' again because it is the same size as before when it wrote 'MORE')

I can even increase a bit more and it still displays 'do you wish...'. Only if I increase it again until I see 'MORE' again, and then reduce size again it displays 'MORE'.

Sounds like a hysteresis curve >.<

@marlonrichert
Copy link
Owner

Thanks for the new video. I have been able to reproduce some of it now. It looks like I made an optimistic rounding error. I'll have a fix ready soon.

@marlonrichert marlonrichert reopened this Aug 5, 2021
@marlonrichert marlonrichert added bug Something isn't working and removed wontfix This will not be worked on labels Aug 5, 2021
@marlonrichert
Copy link
Owner

Should be fixed now. At least, I'm not able to reproduce it anymore. 🙂


PS: If you enjoy using my software, please consider sponsoring me.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants