mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-23 10:21:15 +01:00
Pass the chosen strategy into the suggestion server pty
This commit is contained in:
parent
ab2742537f
commit
b3208b08af
2 changed files with 8 additions and 4 deletions
|
@ -15,12 +15,14 @@ _zsh_autosuggest_async_suggestion_server() {
|
|||
# Output only newlines (not carriage return + newline)
|
||||
stty -onlcr
|
||||
|
||||
local strategy=$1
|
||||
|
||||
while IFS='' read -r -d $'\0' prefix; do
|
||||
# Kill last bg process
|
||||
kill -KILL %1 &>/dev/null
|
||||
|
||||
# Run suggestion search in the background
|
||||
echo -n -E "$(_zsh_autosuggest_strategy_default "$prefix")"$'\0' &
|
||||
echo -n -E "$($strategy "$prefix")"$'\0' &
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -51,7 +53,7 @@ _zsh_autosuggest_async_recreate_pty() {
|
|||
typeset -h REPLY
|
||||
|
||||
# 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
|
||||
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY
|
||||
|
|
|
@ -492,12 +492,14 @@ _zsh_autosuggest_async_suggestion_server() {
|
|||
# Output only newlines (not carriage return + newline)
|
||||
stty -onlcr
|
||||
|
||||
local strategy=$1
|
||||
|
||||
while IFS='' read -r -d $'\0' prefix; do
|
||||
# Kill last bg process
|
||||
kill -KILL %1 &>/dev/null
|
||||
|
||||
# Run suggestion search in the background
|
||||
echo -n -E "$(_zsh_autosuggest_strategy_default "$prefix")"$'\0' &
|
||||
echo -n -E "$($strategy "$prefix")"$'\0' &
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -528,7 +530,7 @@ _zsh_autosuggest_async_recreate_pty() {
|
|||
typeset -h REPLY
|
||||
|
||||
# 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
|
||||
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY
|
||||
|
|
Loading…
Reference in a new issue