Allow loading the plugin in the background

If zle is already active (plugin has been loaded in the background),
just start the widgets and set up the automatic re-binding (if manual
rebind has not been specified).

See GitHub issue #481
This commit is contained in:
Eric Freese 2020-01-26 21:46:58 -07:00
parent 19e375bbc8
commit 767d55eba0
2 changed files with 16 additions and 4 deletions

View file

@ -21,5 +21,11 @@ _zsh_autosuggest_start() {
# Mark for auto-loading the functions that we use
autoload -Uz add-zsh-hook is-at-least
# Start the autosuggestion widgets on the next precmd
# If zle is already running, go ahead and start the autosuggestion widgets.
# Otherwise, wait until the next precmd.
if zle; then
_zsh_autosuggest_start
(( ! ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )) && add-zsh-hook precmd _zsh_autosuggest_start
else
add-zsh-hook precmd _zsh_autosuggest_start
fi

View file

@ -854,5 +854,11 @@ _zsh_autosuggest_start() {
# Mark for auto-loading the functions that we use
autoload -Uz add-zsh-hook is-at-least
# Start the autosuggestion widgets on the next precmd
# If zle is already running, go ahead and start the autosuggestion widgets.
# Otherwise, wait until the next precmd.
if zle; then
_zsh_autosuggest_start
(( ! ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )) && add-zsh-hook precmd _zsh_autosuggest_start
else
add-zsh-hook precmd _zsh_autosuggest_start
fi