From f33b605a63b3d64357fb2f390d07349de9d85013 Mon Sep 17 00:00:00 2001
From: Eric Freese <ericdfreese@gmail.com>
Date: Thu, 26 Jan 2017 16:37:42 -0700
Subject: [PATCH] Move async initialization into `start` function to keep in
 one place

---
 src/async.zsh           | 2 --
 src/start.zsh           | 3 +++
 zsh-autosuggestions.zsh | 5 +++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/async.zsh b/src/async.zsh
index f0dbc2c..81b3268 100644
--- a/src/async.zsh
+++ b/src/async.zsh
@@ -64,5 +64,3 @@ _zsh_autosuggest_async_recreate_pty() {
 	# Set up input handler from the pty
 	zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_suggestion_ready
 }
-
-add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
diff --git a/src/start.zsh b/src/start.zsh
index 0633da3..7a1725e 100644
--- a/src/start.zsh
+++ b/src/start.zsh
@@ -10,6 +10,9 @@ _zsh_autosuggest_start() {
 	_zsh_autosuggest_feature_detect
 	_zsh_autosuggest_check_deprecated_config
 	_zsh_autosuggest_bind_widgets
+
+	_zsh_autosuggest_async_recreate_pty
+	add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
 }
 
 add-zsh-hook precmd _zsh_autosuggest_start
diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh
index 0d17ef7..efdf6d2 100644
--- a/zsh-autosuggestions.zsh
+++ b/zsh-autosuggestions.zsh
@@ -579,8 +579,6 @@ _zsh_autosuggest_async_recreate_pty() {
 	zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_suggestion_ready
 }
 
-add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
-
 #--------------------------------------------------------------------#
 # Start                                                              #
 #--------------------------------------------------------------------#
@@ -592,6 +590,9 @@ _zsh_autosuggest_start() {
 	_zsh_autosuggest_feature_detect
 	_zsh_autosuggest_check_deprecated_config
 	_zsh_autosuggest_bind_widgets
+
+	_zsh_autosuggest_async_recreate_pty
+	add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
 }
 
 add-zsh-hook precmd _zsh_autosuggest_start