Add some error handling to async response handler
We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. In zsh source, see main zle event loop in zle_main.c raw_getbyte function.
This commit is contained in:
parent
93877f6b76
commit
88fe824ddf
|
@ -41,10 +41,14 @@ _zsh_autosuggest_async_request() {
|
|||
# First arg will be fd ready for reading
|
||||
# Second arg will be passed in case of error
|
||||
_zsh_autosuggest_async_response() {
|
||||
# Read everything from the fd and give it as a suggestion
|
||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
||||
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||
# Read everything from the fd and give it as a suggestion
|
||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
||||
|
||||
# Remove the handler and close the fd
|
||||
# Close the fd
|
||||
exec {1}<&-
|
||||
fi
|
||||
|
||||
# Always remove the handler
|
||||
zle -F "$1"
|
||||
exec {1}<&-
|
||||
}
|
||||
|
|
|
@ -720,12 +720,16 @@ _zsh_autosuggest_async_request() {
|
|||
# First arg will be fd ready for reading
|
||||
# Second arg will be passed in case of error
|
||||
_zsh_autosuggest_async_response() {
|
||||
# Read everything from the fd and give it as a suggestion
|
||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
||||
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||
# Read everything from the fd and give it as a suggestion
|
||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
||||
|
||||
# Remove the handler and close the fd
|
||||
# Close the fd
|
||||
exec {1}<&-
|
||||
fi
|
||||
|
||||
# Always remove the handler
|
||||
zle -F "$1"
|
||||
exec {1}<&-
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
|
|
Loading…
Reference in New Issue