more conservative instant prompt activation and cleanup on premature shell exit; see #770

pull/778/head
romkatv 5 years ago
parent d8d6efc4ec
commit f3fb34dd99

@ -5608,7 +5608,7 @@ _p9k_set_instant_prompt() {
[[ -n $RPROMPT ]] || unset RPROMPT [[ -n $RPROMPT ]] || unset RPROMPT
} }
typeset -gri __p9k_instant_prompt_version=26 typeset -gri __p9k_instant_prompt_version=27
_p9k_dump_instant_prompt() { _p9k_dump_instant_prompt() {
local user=${(%):-%n} local user=${(%):-%n}
@ -5639,7 +5639,7 @@ _p9k_dump_instant_prompt() {
$__p9k_intro_no_locale $__p9k_intro_no_locale
(( ! \$+__p9k_instant_prompt_disabled )) || return (( ! \$+__p9k_instant_prompt_disabled )) || return
typeset -gi __p9k_instant_prompt_disabled=1 __p9k_instant_prompt_sourced=$__p9k_instant_prompt_version typeset -gi __p9k_instant_prompt_disabled=1 __p9k_instant_prompt_sourced=$__p9k_instant_prompt_version
[[ -t 0 && -t 1 && -t 2 && \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} && [[ \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} &&
\$TERM_PROGRAM $hyper 'Hyper' && \$+VTE_VERSION == $+VTE_VERSION && \$TERM_PROGRAM $hyper 'Hyper' && \$+VTE_VERSION == $+VTE_VERSION &&
\$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' && \$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' &&
\$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || { __p9k_instant_prompt_sourced=0; return 1; } \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || { __p9k_instant_prompt_sourced=0; return 1; }
@ -5661,6 +5661,8 @@ _p9k_dump_instant_prompt() {
__p9k_instant_prompt_sourced=0 __p9k_instant_prompt_sourced=0
return 1 return 1
fi fi
[[ $ZSH_SUBSHELL == 0 && -z $ZSH_SCRIPT && -z $ZSH_EXECUTION_STRING &&
-t 0 && -t 1 && -t 2 && -o interactive && -o zle && -o no_xtrace ]] || return
zmodload zsh/langinfo zsh/terminfo zsh/system || return zmodload zsh/langinfo zsh/terminfo zsh/system || return
if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then
local loc_cmd=$commands[locale] local loc_cmd=$commands[locale]
@ -5893,34 +5895,41 @@ _p9k_dump_instant_prompt() {
if source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then if source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
_p9k_preinit _p9k_preinit
fi fi
function _p9k_instant_prompt_precmd_first() { function _p9k_instant_prompt_cleanup() {
'$__p9k_intro' (( ZSH_SUBSHELL == 0 && ${+__p9k_instant_prompt_active} )) || return 0
function _p9k_instant_prompt_sched_last() { '$__p9k_intro_no_locale'
(( $+__p9k_instant_prompt_active )) || return 0 unset __p9k_instant_prompt_active
() {
'$__p9k_intro'
exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&- exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&-
unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2 __p9k_instant_prompt_active unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2
typeset -gi __p9k_instant_prompt_erased=1 typeset -gi __p9k_instant_prompt_erased=1
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
if [[ -s $__p9k_instant_prompt_output ]]; then if [[ -s $__p9k_instant_prompt_output ]]; then
cat $__p9k_instant_prompt_output 2>/dev/null command cat $__p9k_instant_prompt_output 2>/dev/null
if (( $1 )); then
local _p9k__ret mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}" local _p9k__ret mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}"
_p9k_prompt_length $mark _p9k_prompt_length $mark
local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
echo -nE - "${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" echo -nE - "${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
fi fi
fi
zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup})
zmodload -F zsh/files b:zf_rm || return zmodload -F zsh/files b:zf_rm || return
local user=${(%):-%n} local user=${(%):-%n}
local root_dir=${__p9k_instant_prompt_dump_file:h} local root_dir=${__p9k_instant_prompt_dump_file:h}
zf_rm -f -- $__p9k_instant_prompt_output $__p9k_instant_prompt_dump_file{,.zwc} $root_dir/p10k-instant-prompt-$user.zsh{,.zwc} $root_dir/p10k-$user/prompt-*(N) 2>/dev/null zf_rm -f -- $__p9k_instant_prompt_output $__p9k_instant_prompt_dump_file{,.zwc} $root_dir/p10k-instant-prompt-$user.zsh{,.zwc} $root_dir/p10k-$user/prompt-*(N) 2>/dev/null
} }
function _p9k_instant_prompt_precmd_first() {
'$__p9k_intro'
function _p9k_instant_prompt_sched_last() {
(( ${+__p9k_instant_prompt_active} )) || return 0
_p9k_instant_prompt_cleanup 1
setopt no_local_options prompt_cr prompt_sp setopt no_local_options prompt_cr prompt_sp
} }
zmodload zsh/sched zmodload zsh/sched
sched +0 _p9k_instant_prompt_sched_last sched +0 _p9k_instant_prompt_sched_last
precmd_functions=(${(@)precmd_functions:#_p9k_instant_prompt_precmd_first}) precmd_functions=(${(@)precmd_functions:#_p9k_instant_prompt_precmd_first})
} }
zshexit_functions=(_p9k_instant_prompt_cleanup $zshexit_functions)
precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions) precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions)
DISABLE_UPDATE_PROMPT=true DISABLE_UPDATE_PROMPT=true
} && unsetopt prompt_cr prompt_sp || true' } && unsetopt prompt_cr prompt_sp || true'
@ -6073,6 +6082,7 @@ function _p9k_clear_instant_prompt() {
fi fi
exec 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_1}>&- {__p9k_fd_2}>&- exec 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_1}>&- {__p9k_fd_2}>&-
unset __p9k_fd_1 __p9k_fd_2 unset __p9k_fd_1 __p9k_fd_2
zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup})
if (( _p9k__can_hide_cursor )); then if (( _p9k__can_hide_cursor )); then
echoti civis echoti civis
_p9k__cursor_hidden=1 _p9k__cursor_hidden=1
@ -6140,7 +6150,7 @@ function _p9k_clear_instant_prompt() {
echo -E - "" echo -E - ""
fi fi
fi fi
cat -- $__p9k_instant_prompt_output command cat -- $__p9k_instant_prompt_output
echo -nE - $sp echo -nE - $sp
zf_rm -f -- $__p9k_instant_prompt_output zf_rm -f -- $__p9k_instant_prompt_output
} 2>/dev/null } 2>/dev/null

Loading…
Cancel
Save