Closed codicodi closed 11 months ago
Hey, thanks for this. I stumbled across the same issue while looking into #753 (see last paragraph of https://github.com/zsh-users/zsh-autosuggestions/pull/753#issuecomment-1694146062).
I was able to produce errors with ZSH_AUTOSUGGEST_MANUAL_REBIND active and sourcing a file async-widget-setup.zsh after the first precmd with the plugin active. If manual rebind is not active or if the widgets are created before the first precmd, then zsh-autosuggestions wraps the widgets and for some reason we don't seem to get any fd conflicts.
The .zshrc:
ZSH_AUTOSUGGEST_MANUAL_REBIND=true
source zsh-autosuggestions.zsh
and async-widget-setup.zsh:
function async-widget-fork() {
exec {fd}< <(echo foo)
zle -M "opened: $fd, autosuggest fd: $_ZSH_AUTOSUGGEST_ASYNC_FD"
}
function async-widget-read() {
zle -M "reading from $fd: $(cat <&$fd)"
}
zle -N async-widget-fork
zle -N async-widget-read
bindkey ^A async-widget-fork
bindkey ^B async-widget-read
Then run ZDOTDIR=$PWD zsh
and:
source async-widget-setup.zsh
This prevents the request cancelling logic from closing an unrelated fd that happens to reuse the same number.
https://github.com/zsh-users/zsh-autosuggestions/blob/a411ef3e0992d4839f0732ebeb9823024afaaaa8/src/async.zsh#L12-L15