Pass the chosen strategy into the suggestion server pty

This commit is contained in:
Eric Freese 2017-01-24 22:48:30 -07:00
parent ab2742537f
commit b3208b08af
2 changed files with 8 additions and 4 deletions

View file

@ -15,12 +15,14 @@ _zsh_autosuggest_async_suggestion_server() {
# Output only newlines (not carriage return + newline) # Output only newlines (not carriage return + newline)
stty -onlcr stty -onlcr
local strategy=$1
while IFS='' read -r -d $'\0' prefix; do while IFS='' read -r -d $'\0' prefix; do
# Kill last bg process # Kill last bg process
kill -KILL %1 &>/dev/null kill -KILL %1 &>/dev/null
# Run suggestion search in the background # Run suggestion search in the background
echo -n -E "$(_zsh_autosuggest_strategy_default "$prefix")"$'\0' & echo -n -E "$($strategy "$prefix")"$'\0' &
done done
} }
@ -51,7 +53,7 @@ _zsh_autosuggest_async_recreate_pty() {
typeset -h REPLY typeset -h REPLY
# Start a new pty running the server function # Start a new pty running the server function
zpty -b $ZSH_AUTOSUGGEST_PTY_NAME _zsh_autosuggest_async_suggestion_server zpty -b $ZSH_AUTOSUGGEST_PTY_NAME "_zsh_autosuggest_async_suggestion_server _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
# Store the fd so we can destroy this pty later # Store the fd so we can destroy this pty later
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY _ZSH_AUTOSUGGEST_PTY_FD=$REPLY

View file

@ -492,12 +492,14 @@ _zsh_autosuggest_async_suggestion_server() {
# Output only newlines (not carriage return + newline) # Output only newlines (not carriage return + newline)
stty -onlcr stty -onlcr
local strategy=$1
while IFS='' read -r -d $'\0' prefix; do while IFS='' read -r -d $'\0' prefix; do
# Kill last bg process # Kill last bg process
kill -KILL %1 &>/dev/null kill -KILL %1 &>/dev/null
# Run suggestion search in the background # Run suggestion search in the background
echo -n -E "$(_zsh_autosuggest_strategy_default "$prefix")"$'\0' & echo -n -E "$($strategy "$prefix")"$'\0' &
done done
} }
@ -528,7 +530,7 @@ _zsh_autosuggest_async_recreate_pty() {
typeset -h REPLY typeset -h REPLY
# Start a new pty running the server function # Start a new pty running the server function
zpty -b $ZSH_AUTOSUGGEST_PTY_NAME _zsh_autosuggest_async_suggestion_server zpty -b $ZSH_AUTOSUGGEST_PTY_NAME "_zsh_autosuggest_async_suggestion_server _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
# Store the fd so we can destroy this pty later # Store the fd so we can destroy this pty later
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY _ZSH_AUTOSUGGEST_PTY_FD=$REPLY