Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Async Behavior is Freezing in Some Terminal #1402

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions async.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
typeset -g ASYNC_VERSION=1.8.6
# Produce debug output from zsh-async when set to 1.
typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0}
# Add sleep duration to give a leeway time for some terminal that haven't load
# all the necessary script when the async job is being dispatch.
typeset -g ASYNC_SLEEP_DURATION=${ASYNC_SLEEP_DURATION=0}

# Execute commands that can manipulate the environment inside the async worker. Return output via callback.
_async_eval() {
Expand All @@ -28,6 +31,8 @@ _async_job() {
# Disable xtrace as it would mangle the output.
setopt localoptions noxtrace

sleep $ASYNC_SLEEP_DURATION

# Store start time for job.
float -F duration=$EPOCHREALTIME

Expand Down
2 changes: 2 additions & 0 deletions lib/worker.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Unique array of async jobs
typeset -ahU SPACESHIP_JOBS=()

ASYNC_SLEEP_DURATION="${SPACESHIP_ASYNC_SLEEP_DURATION=0}"

# Load zsh-async if not loaded yet
spaceship::worker::load() {
if ! (( ASYNC_INIT_DONE )); then
Expand Down