don't use prompt segments with non-hermetic expansions in instant prompt

pull/275/head
romkatv 5 years ago
parent 148a8500c1
commit a1bab30690

@ -533,6 +533,8 @@ _p9k_left_prompt_segment() {
local s='<_p9k_s>' ss='<_p9k_ss>' local s='<_p9k_s>' ss='<_p9k_ss>'
local -i non_hermetic=0
# Segment separator logic: # Segment separator logic:
# #
# if [[ $_p9k_bg == NONE ]]; then # if [[ $_p9k_bg == NONE ]]; then
@ -585,9 +587,11 @@ _p9k_left_prompt_segment() {
p+="\${_p9k_n:=$((t+4))}" # 4 p+="\${_p9k_n:=$((t+4))}" # 4
_p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}'
[[ $_p9k_ret == (|*[^\\])'$('* ]] && non_hermetic=1
local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"}
_p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}' _p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}'
[[ $_p9k_ret == (|*[^\\])'$('* ]] && non_hermetic=1
local content_exp_=${_p9k_ret:+\"$_p9k_ret\"} local content_exp_=${_p9k_ret:+\"$_p9k_ret\"}
if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) || if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) ||
@ -691,9 +695,11 @@ _p9k_left_prompt_segment() {
p+='}' p+='}'
_p9k_cache_set "$p" _p9k_cache_set "$p" $non_hermetic
fi fi
_p9k_non_hermetic_expansion=$_p9k_cache_val[2]
(( $5 )) && _p9k_ret=\"$7\" || _p9k_escape $7 (( $5 )) && _p9k_ret=\"$7\" || _p9k_escape $7
if [[ -z $6 ]]; then if [[ -z $6 ]]; then
_p9k_prompt+="\${\${:-\${P9K_CONTENT::=$_p9k_ret}$_p9k_cache_val[1]" _p9k_prompt+="\${\${:-\${P9K_CONTENT::=$_p9k_ret}$_p9k_cache_val[1]"
@ -756,6 +762,8 @@ _p9k_right_prompt_segment() {
local w='<_p9k_w>' s='<_p9k_s>' local w='<_p9k_w>' s='<_p9k_s>'
local -i non_hermetic=0
# Segment separator logic: # Segment separator logic:
# #
# if [[ $_p9k_bg == NONE ]]; then # if [[ $_p9k_bg == NONE ]]; then
@ -797,9 +805,11 @@ _p9k_right_prompt_segment() {
p+="\${_p9k_n:=$((t+4))}" # 4 p+="\${_p9k_n:=$((t+4))}" # 4
_p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}'
[[ $_p9k_ret == (|*[^\\])'$('* ]] && non_hermetic=1
local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"}
_p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}' _p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}'
[[ $_p9k_ret == (|*[^\\])'$('* ]] && non_hermetic=1
local content_exp_=${_p9k_ret:+\"$_p9k_ret\"} local content_exp_=${_p9k_ret:+\"$_p9k_ret\"}
if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) || if [[ ( $icon_exp_ != '"${P9K_VISUAL_IDENTIFIER}"' && $icon_exp_ == *'$'* ) ||
@ -921,9 +931,11 @@ _p9k_right_prompt_segment() {
p+='}+}' p+='}+}'
p+='}' p+='}'
_p9k_cache_set "$p" _p9k_cache_set "$p" $non_hermetic
fi fi
_p9k_non_hermetic_expansion=$_p9k_cache_val[2]
(( $5 )) && _p9k_ret=\"$7\" || _p9k_escape $7 (( $5 )) && _p9k_ret=\"$7\" || _p9k_escape $7
if [[ -z $6 ]]; then if [[ -z $6 ]]; then
_p9k_prompt+="\${\${:-\${P9K_CONTENT::=$_p9k_ret}$_p9k_cache_val[1]" _p9k_prompt+="\${\${:-\${P9K_CONTENT::=$_p9k_ret}$_p9k_cache_val[1]"
@ -3373,8 +3385,12 @@ function _p9k_build_segment() {
function _p9k_build_instant_segment() { function _p9k_build_instant_segment() {
_p9k_segment_name=${_p9k_segment_name%_joined} _p9k_segment_name=${_p9k_segment_name%_joined}
if (( $+functions[instant_prompt_$_p9k_segment_name] )); then if (( $+functions[instant_prompt_$_p9k_segment_name] )); then
# TODO: Drop segment if it has '$(' in CONTEXT_EXPANSION or VISUAL_IDENTIFIER_EXPANSION. local -i len=$#_p9k_prompt
_p9k_non_hermetic_expansion=0
instant_prompt_$_p9k_segment_name instant_prompt_$_p9k_segment_name
if (( _p9k_non_hermetic_expansion )); then
_p9k_prompt[len+1,-1]=
fi
fi fi
((++_p9k_segment_index)) ((++_p9k_segment_index))
} }
@ -4046,6 +4062,7 @@ function _p9k_prompt_overflow_bug() {
} }
_p9k_init_vars() { _p9k_init_vars() {
typeset -gi _p9k_non_hermetic_expansion
typeset -g _p9k_time typeset -g _p9k_time
typeset -g _p9k_date typeset -g _p9k_date
typeset -gA _p9k_dumped_instant_prompt_sigs typeset -gA _p9k_dumped_instant_prompt_sigs

Loading…
Cancel
Save