Skip to content

Commit

Permalink
Use zpty -r with pattern matching to fetch suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
ericfreese committed Jan 25, 2017
1 parent 5c891af commit b530b0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/async.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ _zsh_autosuggest_async_suggestion_server() {
# First arg will be fd ready for reading
# Second arg will be passed in case of error
_zsh_autosuggest_async_suggestion_ready() {
# while zpty -rt $ZSH_AUTOSUGGEST_PTY_NAME suggestion 2>/dev/null; do
while read -u $_ZSH_AUTOSUGGEST_PTY_FD -d $'\0' suggestion; do
zle _autosuggest-show-suggestion "${suggestion//$'\r'$'\n'/$'\n'}"
done
local suggestion

zpty -rt $ZSH_AUTOSUGGEST_PTY_NAME suggestion '*'$'\0' 2>/dev/null
zle _autosuggest-show-suggestion "${suggestion%$'\0'}"
}

# Recreate the pty to get a fresh list of history events
Expand Down
8 changes: 4 additions & 4 deletions zsh-autosuggestions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ _zsh_autosuggest_async_suggestion_server() {
# First arg will be fd ready for reading
# Second arg will be passed in case of error
_zsh_autosuggest_async_suggestion_ready() {
# while zpty -rt $ZSH_AUTOSUGGEST_PTY_NAME suggestion 2>/dev/null; do
while read -u $_ZSH_AUTOSUGGEST_PTY_FD -d $'\0' suggestion; do
zle _autosuggest-show-suggestion "${suggestion//$'\r'$'\n'/$'\n'}"
done
local suggestion

zpty -rt $ZSH_AUTOSUGGEST_PTY_NAME suggestion '*'$'\0' 2>/dev/null
zle _autosuggest-show-suggestion "${suggestion%$'\0'}"
}

# Recreate the pty to get a fresh list of history events
Expand Down

0 comments on commit b530b0c

Please sign in to comment.