summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-07-17 10:06:34 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-07-17 10:06:34 +0300
commit8b049666242c8b5bde41cd3e6fd20f5fd49cb4f6 (patch)
tree960b68b550f13db8966bac5b0ba456352a6dd9f2
parentc5e24d843bbd77e04567a982bf41215dcdf8f688 (diff)
optimize codegen when VISUAL_IDENTIFIER_EXPANSION doesn't contain $-expansions
-rwxr-xr-xinternal/p10k.zsh16
1 files changed, 10 insertions, 6 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index bee491a5..a6003e72 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -317,9 +317,11 @@ left_prompt_segment() {
_p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}'
local content_exp=$_P9K_RETVAL
- if [[ $icon_exp == '${P9K_VISUAL_IDENTIFIER}' && $content_exp == '${P9K_CONTENT}' ]]; then
- p+="\${_P9K_V::=$icon_"
- [[ $icon_ == *%* ]] && p+=$style_
+ if [[ ( $icon_exp == '${P9K_VISUAL_IDENTIFIER}' || $icon_exp != *'$'* ) &&
+ ( $content_exp == '${P9K_CONTENT}' || $content_exp != *'$'* ) ]]; then
+ [[ $icon_exp == '${P9K_VISUAL_IDENTIFIER}' ]] && _P9K_RETVAL=$icon_ || _p9k_escape $icon_exp
+ p+="\${_P9K_V::=$_P9K_RETVAL"
+ [[ $_P9K_RETVAL == *%* ]] && p+=$style_
p+="}"
else
p+="\${P9K_VISUAL_IDENTIFIER::=$icon_}\${_P9K_V::=$icon_exp$style_}"
@@ -469,9 +471,11 @@ right_prompt_segment() {
_p9k_param $1 CONTENT_EXPANSION '${P9K_CONTENT}'
local content_exp=$_P9K_RETVAL
- if [[ $icon_exp == '${P9K_VISUAL_IDENTIFIER}' && $content_exp == '${P9K_CONTENT}' ]]; then
- p+="\${_P9K_V::=$icon_"
- [[ $icon_ == *%* ]] && p+=$style_
+ if [[ ( $icon_exp == '${P9K_VISUAL_IDENTIFIER}' || $icon_exp != *'$'* ) &&
+ ( $content_exp == '${P9K_CONTENT}' || $content_exp != *'$'* ) ]]; then
+ [[ $icon_exp == '${P9K_VISUAL_IDENTIFIER}' ]] && _P9K_RETVAL=$icon_ || _p9k_escape $icon_exp
+ p+="\${_P9K_V::=$_P9K_RETVAL"
+ [[ $_P9K_RETVAL == *%* ]] && p+=$style_
p+="}"
else
p+="\${P9K_VISUAL_IDENTIFIER::=$icon_}\${_P9K_V::=$icon_exp$style_}"