Skip to content

Commit

Permalink
Send an extra kill signal to the PTY
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed May 31, 2023
1 parent 796ae9d commit 54a221d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Functions/Init/.autocomplete:async
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,25 @@ builtin zle -N history-incremental-search-backward .autocomplete:async:history-i
local -a reply=()
local text=

# WORKAROUND: #441 Directly using $(( [#10] 100 * max( 0, seconds - SECONDS ) ) )) leads to 0 in Zsh 5.9, as the
# result of max() gets converted to an integer _before_ being multiplied.
# WORKAROUND: #441 Directly using
# $(( [#10] 100 * max( 0, seconds - SECONDS ) ) ))
# leads to 0 in Zsh 5.9, as the result of max() gets converted to an
# integer _before_ being multiplied.
builtin zstyle -s :autocomplete: timeout seconds ||
seconds=0.5
local -i timeout=$(( 100 * max( 0, seconds - SECONDS ) ))
zselect -rt $timeout "$fd" &&
zpty -r AUTOCOMPLETE text $'*\C-B'

} always {
zpty -w AUTOCOMPLETE $'\C-C\C-D' # Tell the shell to stop what it's doing and exit.
# Press ^C twice: Once to abort completion, then once to abort the command
# line. Then exit the shell with ^D.
zpty -w AUTOCOMPLETE $'\C-C\C-C\C-D'
zpty -d AUTOCOMPLETE
}
} always {
# Always produce output, so we always reach the callback, so we can close the fd.
# Always produce output, so we always reach the callback, so we can close
# the fd.
print -rNC1 -- "$SECONDS" "${text%$'\0\C-B'}"
}
}
Expand Down

0 comments on commit 54a221d

Please sign in to comment.