zsh-autosuggestions: Maybe fix for slow pastes
Howdy, I think I may have a solution for slow pastes (#141 #219) but I’m not sure if there are problems with it or what the best way to actually implement it is.
I believe that the paste slowdown comes from the additional zle invocation to call the original widget on self-insert. Rather than doing that, if, on disable, we replace self-insert with the original widget and then on enable, we replace it back, things are snappy.
Here is my naive implementation:
# Disable suggestions
_zsh_autosuggest_disable() {
typeset -g _ZSH_AUTOSUGGEST_DISABLED
_zsh_autosuggest_clear
zle -N self-insert url-quote-magic
}
# Enable suggestions
_zsh_autosuggest_enable() {
unset _ZSH_AUTOSUGGEST_DISABLED
zle -N self-insert _zsh_autosuggest_bound_1_self-insert
if [ $#BUFFER -gt 0 ]; then
_zsh_autosuggest_fetch
fi
}
Obviously we shouldn’t hard-code url-quote-magic or _zsh_autosuggest_bound_1_self-insert but I wasn’t sure of the best way to get the right ones in there.
Thoughts? Suggestions? Thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (3 by maintainers)
Links to this issue
Commits related to this issue
- Hack: Make paste fast again https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 — committed to hthuwal/scripts by hthuwal 5 years ago
- Zsh: Make Paste Fast Again Thanks @hthuwal https://github.com/zsh-users/zsh-autosuggestions/issues/238 — committed to dufferzafar/dotfiles by dufferzafar 5 years ago
- speed up pasting with zsh-autosuggestions ref: https://github.com/zsh-users/zsh-autosuggestions/issues/238\#issuecomment-389324292 — committed to dakshshah96/dotfiles by dakshshah96 4 years ago
- Fix slow paste into zsh Solution from: https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 — committed to Maxwell-lt/machine-configuration by Maxwell-lt 4 years ago
- add faster command-line pasting with autosuggest https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 → https://git.io/pasteinit-pastefinish — committed to LucasLarson/dotfiles by LucasLarson 3 years ago
- add faster command-line pasting with autosuggest https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 → https://git.io/pasteinit-pastefinish — committed to LucasLarson/dotfiles by LucasLarson 3 years ago
- add faster command-line pasting with autosuggest https://github.com/zsh-users/zsh-autosuggestions/issues/238#issuecomment-389324292 → https://git.io/pasteinit-pastefinish — committed to LucasLarson/dotfiles by LucasLarson 3 years ago
Works for me. Thanks again for your help.
For posterity:
The proposed fix works for me but why is it not added to zsh-autosuggestions and needs to be applied manually?
I’d also like to know why this can’t be included directly in zsh-autosuggestions
Where does one use apply this?
I put mine in my
.zshrcI fixed this issue by adding the following line to my
.zshrcconfigmaybe this advice should be added to the readme. What do you think @ericfreese?
@bric3, I experience this bug as well. The above fix isn’t really intended to address that, it’s intended to make pasting fast, which it does for me. It seems there could still be an issue with either that fix or with zsh-autosuggestions.