From 56f10c3b5dac558a7fcc7aa47459e4ac0eec3dc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20Cegli=C5=84ski?= <rob.ceglinski@gmail.com>
Date: Fri, 17 Sep 2021 00:07:03 +0200
Subject: [PATCH] Always reset file descriptor after consuming it

This prevents the request cancelling logic from closing an unrelated fd that happens to reuse the same number.
---
 src/async.zsh           | 1 +
 zsh-autosuggestions.zsh | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/async.zsh b/src/async.zsh
index 218eb26..9a02280 100644
--- a/src/async.zsh
+++ b/src/async.zsh
@@ -73,4 +73,5 @@ _zsh_autosuggest_async_response() {
 
 	# Always remove the handler
 	zle -F "$1"
+	_ZSH_AUTOSUGGEST_ASYNC_FD=
 }
diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh
index b19cac7..98d1ec2 100644
--- a/zsh-autosuggestions.zsh
+++ b/zsh-autosuggestions.zsh
@@ -828,6 +828,7 @@ _zsh_autosuggest_async_response() {
 
 	# Always remove the handler
 	zle -F "$1"
+	_ZSH_AUTOSUGGEST_ASYNC_FD=
 }
 
 #--------------------------------------------------------------------#