fix(lib/git): turn off async prompt for zsh < 5.0.6
We removed this mitigation in 0c80a063 because of an assumption
that the issue had been fixed, but it looks like zsh < 5.0.6 has
other issues (see #12360), so we need to disable it for real.
Fixes #12360
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index b257d01a482acdf24ba87c978bc907c15a051e9d..db6c9174cac223740371e88bbe9a174892d5ec95 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -39,8 +39,13 @@ function _omz_git_prompt_info() {
6 echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
7 }
8 9-# Use async version if setting is enabled or undefined
10-if zstyle -T ':omz:alpha:lib:git' async-prompt; then
11+# Use async version if setting is enabled, or unset but zsh version is at least 5.0.6.
12+# This avoids async prompt issues caused by previous zsh versions:
13+# - https://github.com/ohmyzsh/ohmyzsh/issues/12331
14+# - https://github.com/ohmyzsh/ohmyzsh/issues/12360
15+# TODO(2024-06-12): @mcornella remove workaround when CentOS 7 reaches EOL
16+if zstyle -t ':omz:alpha:lib:git' async-prompt \
17+ || { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
18 function git_prompt_info() {
19 if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
20 echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"