Zsh-autocomplete: History menu doesn't insert completion when part of the word is typed (Oh-My-Zsh)

Created on 16 Oct 2020  ·  31Comments  ·  Source: marlonrichert/zsh-autocomplete

Environment

  • Zsh version: 5.5.1
  • zsh-autocomplete version: 0da3bdc1dd7c97a6afba53e922483a8be70acb4d
  • Latest Oh-My-Zsh (manually updated using omz update today, 16 Oct 2020)

Please report if the bug occurs without config files:

$ cd $(mktemp -d)  # Create a temp dir and enter it.
$ ZDOTDIR=$PWD HOME=$PWD zsh -f  # Start a subshell in it without config files.
% source path/to/zsh-autocomplete.plugin.zsh  # Source the plugin.
% # Try to reproduce your bug...

Does the bug occur without config files?

  • [ ] Yes
  • [x] No

If not, gradually add lines from your config file to the subshell until the bug appears.

Which combination of config causes the bug to appear?

source /root/.oh-my-zsh/oh-my-zsh.sh
source /root/.oh-my-zsh/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh

Steps to reproduce

  1. Let's say I want to type nano .zshrc which I've entered before so it's going to appear in history menu
  2. I typed na and pressed arrow up
  3. Select nano .zshrc and enter

Expected behavior

It should be saying nano .zshrc in my terminal

Actual behavior

It goes back to na
If there's nothing in the terminal (me without typing na), it actually works.

Bug report

Most helpful comment

After creating a temp ZSH shell and just sourcing the completion.zsh and zsh-autocompelete, the first command as well as the second command after the first commands work perfectly.

All 31 comments

@aulialuthfi99 I am not able to reproduce this. I tried it as follows:

$ cd "$(mktemp -d)"; ZDOTDIR=$PWD HOME=$PWD zsh -f
% source path/to/oh-my-zsh.sh 
% source path/to/zsh-autocomplete.plugin.zsh
% nano .zshrc

I then typed na and pressed Arrow Up. Now my command line says nano .zshrc.

Can you please try with the _exact_ steps above and tell me whether it works the same for you? If so, then there must be something else in your config that's causing the problem.

@marlonrichert Ah sorry forgot to mention one thing: It doesn't work when there's multiple entry in the history menu. When there's only one entry, it'll just work straight up. Have a look. Sorry for using imgur, for some reason I couldn't upload image here.

@aulialuthfi99 OK, I now did the following:

$ cd "$(mktemp -d)"; ZDOTDIR=$PWD HOME=$PWD zsh -f
% source path/to/oh-my-zsh.sh 
% source path/to/zsh-autocomplete.plugin.zsh
% nano .zshrc
% netstat -natp
% nano asd.txt

I then typed na and pressed . Still works correctly for me.

Are you sure you don't have anything else that's interfering?

I'm pretty sure I don't have anything that gonna interfere with your plugin. Even I tried to uninstall zsh 5.5.1 and omz then install zsh 5.8 + omz, still same. Might be worth mentioning that I'm using CentOS 8.

@aulialuthfi99 Did you try the exact steps I wrote above?

@marlonrichert yup, I did.

Then I have no idea. I don't have CentOS, so I cannot test with that.

@artfulrobot @cenk1cenk2 @mehanoid Is this the same issue that you had? Are you still experiencing it on the master branch? Was it ever fixed for you on master? Or is this a regression?

Yes pretty much so it seems similar.

I pulled master if i remember correctly 2 days ago. It did not fix it for me.

Can you try to create a reproducible test case for me, using the following?

$ cd "$(mktemp -d)"; ZDOTDIR=$PWD HOME=$PWD zsh -f
% source path/to/zsh-autocomplete.plugin.zsh
% # add steps to reproduce the bug

I still haven't been able to reproduce it.

Also, artfulrobot reported that 005da66 was the last commit for him where this problem did not yet occur. Can you please git checkout 005da66 and report whether that makes the problem go away for you, too?

@aulialuthfi99 @artfulrobot @cenk1cenk2 @mehanoid Are all of you seeing this problem only with OhMyZsh? Or can you reproduce it without OMZ, too?

@marlonrichert I've actually given up on oh-my-zsh as I found it's undocumented "helpers" were more of a hindrance! I am not seeing this behaviour (I'm still on d7e7b05).

  • With the clean ZSH installation I can not reproduce the issue. So the culprit can be Oh-My-ZSH.
  • fd16c5e is the last commit that i found working for me, which had the older fzf style history search.

With the clean ZSH installation I can not reproduce the issue. So the culprit can be Oh-My-ZSH.

Thanks, that's very useful info.

Can you please try the following?

$ cd "$(mktemp -d)"; ZDOTDIR=$PWD HOME=$PWD zsh -f
% source path/to/oh-my-zsh.sh 
% source path/to/zsh-autocomplete.plugin.zsh

Does the problem occur then?

With the clean ZSH installation I can not reproduce the issue. So the culprit can be Oh-My-ZSH.

Thanks, that's very useful info.

Can you please try the following?

$ cd "$(mktemp -d)"; ZDOTDIR=$PWD HOME=$PWD zsh -f
% source path/to/oh-my-zsh.sh 
% source path/to/zsh-autocomplete.plugin.zsh

Does the problem occur then?

When I try it exactly like this, the problem exist. But, like @cenk1cenk2 said, without the oh-my-zsh.sh line, it works just fine.

Can you try the following?

  1. Make a backup of .oh-my-zsh/lib.
  2. For each file in .oh-my-zsh/lib:

    1. Delete the file.

    2. Run a clean subshell with OMZ and zsh-autocomplete, as described above.

    3. See if the problem occurs.

Does deleting any of these files cause the problem to go away? If so, which one?

@marlonrichert deleting completion.zsh in .oh-my-zsh/lib fixed it apparently.

Great! That narrows it down a lot. I’ll see what I can do fix it.

Cool! Can't wait for next update 👍

Hm, I can’t see anything in there that obviously would be a problem.

In the clean subshell, can you please paste in the lines from https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/completion.zsh one by one and test which one causes the problem?

Hi, I'm suffering from the same problem.

I copy .oh-my-zsh/lib/completion.zsh to a file try, comment some of the lines and run the following:

$ zsh -f
% source /path/to/try
% source /path/to/zsh-autocomplete.plugin.zsh

If line 1-13 are left uncommented, the completion goes well. But if I uncomment line 14 further, the problem occurs, so I think it is the line 14 that causes the problem, which says

zstyle ':completion:*:*:*:*:*' menu select

@wu-qing-157 Thanks! Let’s hope that is indeed the problem, as I still haven’t been able to reproduce it.

By the way, are you all on Zsh 5.5? Perhaps I’m not experiencing it because I’m on Zsh 5.8.

dnf gave me 5.5.1 so yeah

I'm on zsh 5.8, Ubuntu with Windows Subsystem for Linux

Wait, I also tried it with zsh 5.8 on CentOS 8 in my VPS, still doesn't work. Lemme try it in Kubuntu on my laptop this evening.

After sourcing .oh-my-zsh/lib/completion.zsh and zsh-autocomplete.plugin.zsh, if you run the following line, does the problem go away?

  zstyle ':completion:*:*:*:*:*' menu 'yes select=long-list'

Or failing that, what if you run this?

  zstyle -d ':completion:*:*:*:*:*' menu

After creating a temp ZSH shell and just sourcing the completion.zsh and zsh-autocompelete, the first command as well as the second command after the first commands work perfectly.

After sourcing .oh-my-zsh/lib/completion.zsh and zsh-autocomplete.plugin.zsh, if you run the following line, does the problem go away?

  zstyle ':completion:*:*:*:*:*' menu 'yes select=long-list'

Or failing that, what if you run this?

  zstyle -d ':completion:*:*:*:*:*' menu

@marlonrichert Just tried loading omz with completion lib commented on line 14 onwards and load your plugin afterwards, both command run perfectly fine and doesn't break history menu completion.

Alright, it's fixed now. Thanks for helping out!

We should thank you for your time on this, very grateful about it much thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcassee picture jcassee  ·  7Comments

jcassee picture jcassee  ·  6Comments

windowswithoutborders picture windowswithoutborders  ·  6Comments

g4cm4n picture g4cm4n  ·  6Comments

weilbith picture weilbith  ·  7Comments