From a0fcd81ce19947339aea3b05ec57d6680ba99548 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Fri, 17 Feb 2017 22:40:23 -0700 Subject: [PATCH] Destroy zpty on load if it already exists --- src/async.zsh | 6 +++--- zsh-autosuggestions.zsh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/async.zsh b/src/async.zsh index 60055b9..be331ba 100644 --- a/src/async.zsh +++ b/src/async.zsh @@ -85,9 +85,9 @@ _zsh_autosuggest_async_pty_create() { } _zsh_autosuggest_async_pty_destroy() { - if [ -n "$_ZSH_AUTOSUGGEST_PTY_FD" ]; then + if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then # Remove the input handler - zle -F $_ZSH_AUTOSUGGEST_PTY_FD + zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null # Destroy the zpty zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null @@ -102,7 +102,7 @@ _zsh_autosuggest_async_pty_recreate() { _zsh_autosuggest_async_start() { typeset -g _ZSH_AUTOSUGGEST_PTY_FD - _zsh_autosuggest_async_pty_create + _zsh_autosuggest_async_pty_recreate # We recreate the pty to get a fresh list of history events add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index dc7d1a7..2e612ca 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -579,9 +579,9 @@ _zsh_autosuggest_async_pty_create() { } _zsh_autosuggest_async_pty_destroy() { - if [ -n "$_ZSH_AUTOSUGGEST_PTY_FD" ]; then + if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then # Remove the input handler - zle -F $_ZSH_AUTOSUGGEST_PTY_FD + zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null # Destroy the zpty zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null @@ -596,7 +596,7 @@ _zsh_autosuggest_async_pty_recreate() { _zsh_autosuggest_async_start() { typeset -g _ZSH_AUTOSUGGEST_PTY_FD - _zsh_autosuggest_async_pty_create + _zsh_autosuggest_async_pty_recreate # We recreate the pty to get a fresh list of history events add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate