mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-29 07:34:11 +08:00
Ensure we always destroy the zpty
If running in sync mode and a completion takes a long time, the user can ^C out of it. Without this patch, the pty will not be destroyed in this case and the next time we go to create it, it will fail, making the shell unusable.
This commit is contained in:
parent
302bd7c059
commit
4869a757c8
|
@ -86,6 +86,7 @@ _zsh_autosuggest_strategy_completion() {
|
||||||
zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t'
|
zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
# The completion result is surrounded by null bytes, so read the
|
# The completion result is surrounded by null bytes, so read the
|
||||||
# content between the first two null bytes.
|
# content between the first two null bytes.
|
||||||
zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0'
|
zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0'
|
||||||
|
@ -93,7 +94,8 @@ _zsh_autosuggest_strategy_completion() {
|
||||||
# On older versions of zsh, we sometimes get extra bytes after the
|
# On older versions of zsh, we sometimes get extra bytes after the
|
||||||
# second null byte, so trim those off the end
|
# second null byte, so trim those off the end
|
||||||
suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}"
|
suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}"
|
||||||
|
} always {
|
||||||
# Destroy the pty
|
# Destroy the pty
|
||||||
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME
|
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -556,6 +556,7 @@ _zsh_autosuggest_strategy_completion() {
|
||||||
zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t'
|
zpty -w $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME $'\t'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
# The completion result is surrounded by null bytes, so read the
|
# The completion result is surrounded by null bytes, so read the
|
||||||
# content between the first two null bytes.
|
# content between the first two null bytes.
|
||||||
zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0'
|
zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0'
|
||||||
|
@ -563,10 +564,11 @@ _zsh_autosuggest_strategy_completion() {
|
||||||
# On older versions of zsh, we sometimes get extra bytes after the
|
# On older versions of zsh, we sometimes get extra bytes after the
|
||||||
# second null byte, so trim those off the end
|
# second null byte, so trim those off the end
|
||||||
suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}"
|
suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}"
|
||||||
|
} always {
|
||||||
# Destroy the pty
|
# Destroy the pty
|
||||||
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME
|
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
# History Suggestion Strategy #
|
# History Suggestion Strategy #
|
||||||
|
|
Loading…
Reference in New Issue
Block a user