mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
style: optimize getting async handler from fd
This commit is contained in:
parent
42b22ecf7d
commit
b5349dc137
1 changed files with 2 additions and 7 deletions
|
|
@ -44,7 +44,7 @@ function _omz_register_handler {
|
|||
# Set up async handlers and callbacks
|
||||
function _omz_async_request {
|
||||
local -i ret=$?
|
||||
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT _OMZ_ASYNC_HANDLERS
|
||||
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
|
||||
|
||||
# executor runs a subshell for all async requests based on key
|
||||
local handler
|
||||
|
|
@ -90,8 +90,6 @@ function _omz_async_request {
|
|||
|
||||
# Save FD for handler
|
||||
_OMZ_ASYNC_FDS[$handler]=$fd
|
||||
# Save handler name for callback
|
||||
_OMZ_ASYNC_HANDLERS[$fd]=$handler
|
||||
|
||||
# There's a weird bug here where ^C stops working unless we force a fork
|
||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||
|
|
@ -115,7 +113,7 @@ function _omz_async_callback() {
|
|||
|
||||
if [[ -z "$err" || "$err" == "hup" ]]; then
|
||||
# Get handler name from fd
|
||||
local handler=${_OMZ_ASYNC_HANDLERS[$fd]}
|
||||
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
||||
|
||||
# Store old output which is supposed to be already printed
|
||||
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||
|
|
@ -136,9 +134,6 @@ function _omz_async_callback() {
|
|||
# Always remove the handler
|
||||
zle -F "$fd"
|
||||
|
||||
# Remove the fd => handle name association
|
||||
unset '_OMZ_ASYNC_HANDLERS[$fd]'
|
||||
|
||||
# Unset global FD variable to prevent closing user created FDs in the precmd hook
|
||||
_OMZ_ASYNC_FDS[$handler]=-1
|
||||
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue