From b3208b08af4e40fbc6a040b0ad9455f33c236f3b Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Tue, 24 Jan 2017 22:48:30 -0700 Subject: [PATCH] Pass the chosen strategy into the suggestion server pty --- src/async.zsh | 6 ++++-- zsh-autosuggestions.zsh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/async.zsh b/src/async.zsh index 18dbb9d..1d2ae87 100644 --- a/src/async.zsh +++ b/src/async.zsh @@ -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 diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 246e96d..2dc5141 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -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