v0.1.x - Breaks terminfo-based bindings for zsh-history-substring-search #101
We're talking about the list of widgets that trigger the autosuggest clear action, which removes the grey suggestion from the buffer. When you trigger a history command like substring search, you're usually not interested in the previous suggestion so we want to remove it. That's what the second line in the readme does- adds the two substring search widgets to the list of widgets that clear the suggestion.
There is another problem though, which is that the history substring widgets sometimes call the up/down line or history widgets, which are added to the list (the clear list mentioned above) by default. This has the effect of creating an infinite loop and crashing your terminal session, so we want to remove those up/down line widgets from the list, breaking the loop. That's what the first line in the readme does.
But the history substring widgets should work without any extra configuration. They just (a) won't clear the suggestion from the end of the buffer when triggered and (b) will crash your terminal session if triggered when the buffer is empty.
First line in the readme addresses (b), second line addresses (a).
That being said, please confirm you have the most recent commit of the v0.1.x branch installed and that you have the history substring search widgets bound correctly.
Also, what version of zsh? What operating system? What other plugins are you using? What is in your .zshrc?
If you can, please try temporarily removing all of your other plugins and verifying that the problem still exists. If you can isolate the problem it will be much easier to fix.
Thanks for the explanations!
That being said, please confirm you have the most recent commit of the v0.1.x branch installed
Yes I'm on 6dd93ed from Sat Jan 30 03:20:52 2016 -0700
Also, what version of zsh? What operating system? What other plugins are you using? What is in your .zshrc?
I'm running zsh 5.2 within tmux 2.1 on Arch Linux x64, with oh-my-zsh.
- oh-my-zsh plugins:
virtualenvwrapper colored-man-pages httpie npm pip git python sudo history-substring-search docker zsh-navigation-tools zsh-syntax-highlighting - Manually-sourced plugins:
autojump, autosuggestions - A few minor aliases and exports
- Sourcing of autosuggestions is done with:
source $HOME/.zsh-autosuggestions/autosuggestions.zsh
unset COMPLETION_WAITING_DOTS # https://github.com/tarruda/zsh-autosuggestions#known-issues
# Remove forward-char widgets from ACCEPT
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=("${(@)ZSH_AUTOSUGGEST_ACCEPT_WIDGETS:#forward-char}")
# Add forward-char widgets to PARTIAL_ACCEPT
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(forward-char)
zle-line-init() {
autosuggest_start
}
zle -N zle-line-init
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=("${(@)ZSH_AUTOSUGGEST_CLEAR_WIDGETS:#(up|down)-line-or-history}")
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(history-substring-search-up history-substring-search-down)Please confirm that you have the history substring search widgets bound correctly.
Here is what I set for history-substring-search:
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
setopt HIST_IGNORE_ALL_DUPSIf you can, please try temporarily removing all of your other plugins and verifying that the problem still exists. If you can isolate the problem it will be much easier to fix.
Doing this and coming back.
Thanks for all the details :)
I'm running zsh 5.2 within tmux 2.1
There was another issue reported with tmux (#97). Might be worth trying it without tmux to see if that's what's causing the trouble.
Sourcing of autosuggestions is done with: ...
This all looks fine to me. The lines from the readme are working for me with zsh-autosuggestions and zsh-history-substring-search both enabled. I'm on a mac with zsh 5.2 (no tmux) and no extra plugins.
Doing this and coming back.
Let me know what you find!
Another thing to try would be to disable the autosuggestions plugin and see if the problem persists. If so, it's likely not a problem with this plugin, but something else.
My mistake! My problem had nothing to do with zsh-autosuggestions, I just missed these bindings documented by history-substring-search:
# bind UP and DOWN arrow keys (compatibility fallback
# for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users)
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-downI remember removing them doing cleanup a few months ago and thinking I didn't need them. Turns out for some reason I still do! (might have to see why, though, I'm running none of the systems mentioned, and use a recent zsh/vte...). Sorry for the false alert, closing.
@ericfreese (ccing @sunaku who maintains history-substring-search) one thing though: more testing reveals that, unlike mentioned by history-substring-search's README, it's not my OS that cause the new bindings to fail, it's zsh-autosuggestions.
Said differently, with no plugins, out of tmux, the recommended bindings ("$terminfo[kcuu1]" / "$terminfo[kcud1]") do work, but they stop working as soon as I activate zsh-autosuggestions. What should we do?
- Is there something you can do on
zsh-autosuggestionsside to not break"$terminfo[kcuu1]"/"$terminfo[kcud1]"inhistory-substring-searchside? - ... or is it inevitable, and in this case I'll create a README pull request on history-substring-search mentioning the "compatibility fallback" is necessary for
zsh-autosuggestionsv0.1.x too.
the recommended bindings do work, but they stop working as soon as I activate zsh-autosuggestions
That's strange. I can't imagine any way that the autosuggest plugin would interfere with that. Would you be willing to try commenting out large chunks of the autosuggest plugin and re-testing to see which bit is causing this?
Just tried reproducing with an ArchLinux VM.
Using #5 from here: http://virtualboxes.org/images/archlinux/
- Archlinux 2014.09
- zsh 5.2 (x86_64-unknown-linux-gnu)
Installed zsh-history-substring-search (7a4b54b):
$ git clone https://github.com/zsh-users/zsh-history-substring-search ~/.zsh-history-substring-search
Wrote to .zshrc:
source ~/.zsh-history-substring-search/zsh-history-substring-search.zsh
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
Tried it out and up/down arrows work as expected, calling the history-substring-search widgets.
Then installed zsh-autosuggestions (72f3c7c):
$ git clone -b v0.1.x https://github.com/tarruda/zsh-autosuggestions ~/.zsh-autosuggestions
And added to bottom of .zshrc:
source ~/.zsh-autosuggestions/autosuggestions.zsh
autosuggest_start
Tried it out and up/down arrows work as expected, calling the history-substring-search widgets.
Also tried it with zle-line-init, but it still worked as expected:
source ~/.zsh-autosuggestions/autosuggestions.zsh
zle -N zle-line-init autosuggest_start
Not sure what's going on with your configuration, but I think I'll need more debugging from your end before I can do much to fix it.
Confirming your bare-bones (non-) reproduction scenario; trying to narrow down on the problem on my side.
Problem came from using both zle -N zle-line-init autosuggest_start and oh-my-zsh :-/
Staying with oh-my-zsh but using autosuggest_start instead of zle -N zle-line-init autosuggest_start fixed the problem for me.
For a new user the current 0.1.x README looks good. For old users that have the zle line in their current .zshrc, what about a note mentioning to not use zle?
# Enable autosuggestions (do *not* use zle here, it can conflict with other oh-my-zsh plugins)
autosuggest_startAwesome, glad this is resolved. Thanks for your work tracking it down.
For old users that have the zle line in their current .zshrc, what about a note mentioning to not use zle?
This is a good idea. There's a deprecation warning too, which would be a good place to tell them not to use it. I'll add this soon.
There's a deprecation warning too, which would be a good place to tell them not to use it. I'll add this soon.
Even better! Thanks for your work
Hey.
I'm trying
v0.1.xat home, and noticedzsh-history-substring-search(initialized as an oh-my-zsh plugin) no longer works.I see there's a nice zsh-history-substring-search entry in README.md, but I don't understand it. What should I do to get it cohabit with autosuggestions? What does "You'll also want to remove up-line-or-history and down-line-or-history from the list" mean? (which list are we talking about?)
I tried adding the two lines mentioned, without success.
Thanks for the help :)