mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Merge pull request #359 from zsh-users/fixes/async-bad-file-descriptor
Fixes/async bad file descriptor
This commit is contained in:
commit
b8bf86f6ab
2 changed files with 20 additions and 10 deletions
|
@ -10,8 +10,9 @@ _zsh_autosuggest_async_request() {
|
||||||
|
|
||||||
# If we've got a pending request, cancel it
|
# If we've got a pending request, cancel it
|
||||||
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
||||||
# Close the file descriptor
|
# Close the file descriptor and remove the handler
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
|
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||||
|
|
||||||
# Zsh will make a new process group for the child process only if job
|
# Zsh will make a new process group for the child process only if job
|
||||||
# control is enabled (MONITOR option)
|
# control is enabled (MONITOR option)
|
||||||
|
@ -49,10 +50,14 @@ _zsh_autosuggest_async_request() {
|
||||||
# First arg will be fd ready for reading
|
# First arg will be fd ready for reading
|
||||||
# Second arg will be passed in case of error
|
# Second arg will be passed in case of error
|
||||||
_zsh_autosuggest_async_response() {
|
_zsh_autosuggest_async_response() {
|
||||||
# Read everything from the fd and give it as a suggestion
|
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
# 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"
|
zle -F "$1"
|
||||||
exec {1}<&-
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -689,8 +689,9 @@ _zsh_autosuggest_async_request() {
|
||||||
|
|
||||||
# If we've got a pending request, cancel it
|
# If we've got a pending request, cancel it
|
||||||
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
|
||||||
# Close the file descriptor
|
# Close the file descriptor and remove the handler
|
||||||
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
|
||||||
|
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
|
||||||
|
|
||||||
# Zsh will make a new process group for the child process only if job
|
# Zsh will make a new process group for the child process only if job
|
||||||
# control is enabled (MONITOR option)
|
# control is enabled (MONITOR option)
|
||||||
|
@ -728,12 +729,16 @@ _zsh_autosuggest_async_request() {
|
||||||
# First arg will be fd ready for reading
|
# First arg will be fd ready for reading
|
||||||
# Second arg will be passed in case of error
|
# Second arg will be passed in case of error
|
||||||
_zsh_autosuggest_async_response() {
|
_zsh_autosuggest_async_response() {
|
||||||
# Read everything from the fd and give it as a suggestion
|
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||||
zle autosuggest-suggest -- "$(cat <&$1)"
|
# 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"
|
zle -F "$1"
|
||||||
exec {1}<&-
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
Loading…
Reference in a new issue