mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Destroy old pty even if it's no longer running (#249)
For unknown reasons, the pty will occasionally quit running. In these cases, we still want to remove it so that a fresh one can be created. We don't actually need this check because error messages from `zle` and `zpty` are redirected to /dev/null. One sure way to kill all currently running pty's is to run `exit` in a subshell. Even without zsh-autosuggestions loaded, the following works: % zmodload zsh/zpty % zpty -b foo cat % zpty -b bar cat % zpty (31689) bar: cat (31666) foo: cat % $(exit) % zpty (finished) bar: cat (finished) foo: cat
This commit is contained in:
parent
726bc4eb5c
commit
df5fb858aa
3 changed files with 18 additions and 12 deletions
|
@ -26,6 +26,16 @@ context 'with asynchronous suggestions enabled' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'exiting a subshell' do
|
||||||
|
it 'should not cause error messages to be printed' do
|
||||||
|
session.run_command('$(exit)')
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
expect(session.content).to eq('$(exit)')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,13 +83,11 @@ _zsh_autosuggest_async_pty_create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zsh_autosuggest_async_pty_destroy() {
|
_zsh_autosuggest_async_pty_destroy() {
|
||||||
if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then
|
|
||||||
# Remove the input handler
|
# Remove the input handler
|
||||||
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
|
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
|
||||||
|
|
||||||
# Destroy the zpty
|
# Destroy the zpty
|
||||||
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
|
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_zsh_autosuggest_async_pty_recreate() {
|
_zsh_autosuggest_async_pty_recreate() {
|
||||||
|
|
|
@ -661,13 +661,11 @@ _zsh_autosuggest_async_pty_create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zsh_autosuggest_async_pty_destroy() {
|
_zsh_autosuggest_async_pty_destroy() {
|
||||||
if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then
|
|
||||||
# Remove the input handler
|
# Remove the input handler
|
||||||
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
|
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
|
||||||
|
|
||||||
# Destroy the zpty
|
# Destroy the zpty
|
||||||
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
|
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_zsh_autosuggest_async_pty_recreate() {
|
_zsh_autosuggest_async_pty_recreate() {
|
||||||
|
|
Loading…
Reference in a new issue