Compare commits

...

2 Commits

Author SHA1 Message Date
Eric Freese
767d55eba0 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
2020-01-26 21:49:59 -07:00
Eric Freese
19e375bbc8 cleanup: Consolidate autoloads 2020-01-26 21:15:47 -07:00
3 changed files with 22 additions and 10 deletions

View File

@@ -18,6 +18,14 @@ _zsh_autosuggest_start() {
_zsh_autosuggest_bind_widgets _zsh_autosuggest_bind_widgets
} }
# Start the autosuggestion widgets on the next precmd # Mark for auto-loading the functions that we use
autoload -Uz add-zsh-hook autoload -Uz add-zsh-hook is-at-least
# 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 add-zsh-hook precmd _zsh_autosuggest_start
fi

View File

@@ -45,8 +45,6 @@ _zsh_autosuggest_capture_completion_widget() {
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
_zsh_autosuggest_capture_setup() { _zsh_autosuggest_capture_setup() {
autoload -Uz is-at-least
# There is a bug in zpty module in older zsh versions by which a # There is a bug in zpty module in older zsh versions by which a
# zpty that exits will kill all zpty processes that were forked # zpty that exits will kill all zpty processes that were forked
# before it. Here we set up a zsh exit hook to SIGKILL the zpty # before it. Here we set up a zsh exit hook to SIGKILL the zpty

View File

@@ -541,8 +541,6 @@ _zsh_autosuggest_capture_completion_widget() {
zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget zle -N autosuggest-capture-completion _zsh_autosuggest_capture_completion_widget
_zsh_autosuggest_capture_setup() { _zsh_autosuggest_capture_setup() {
autoload -Uz is-at-least
# There is a bug in zpty module in older zsh versions by which a # There is a bug in zpty module in older zsh versions by which a
# zpty that exits will kill all zpty processes that were forked # zpty that exits will kill all zpty processes that were forked
# before it. Here we set up a zsh exit hook to SIGKILL the zpty # before it. Here we set up a zsh exit hook to SIGKILL the zpty
@@ -853,6 +851,14 @@ _zsh_autosuggest_start() {
_zsh_autosuggest_bind_widgets _zsh_autosuggest_bind_widgets
} }
# Start the autosuggestion widgets on the next precmd # Mark for auto-loading the functions that we use
autoload -Uz add-zsh-hook autoload -Uz add-zsh-hook is-at-least
# 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 add-zsh-hook precmd _zsh_autosuggest_start
fi