1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-26 17:01:56 +00:00

fix a few bugs in parsing

This commit is contained in:
romkatv 2020-01-11 11:45:23 +01:00
parent 57b500d083
commit b8c9e83661

View file

@ -21,6 +21,9 @@ typeset -gA _p9k_skip_token=(
'while' '' 'while' ''
'until' '' 'until' ''
'do' '' 'do' ''
'done' ''
'esac' ''
'end' ''
'coproc' '' 'coproc' ''
'nocorrect' '' 'nocorrect' ''
'time' '' 'time' ''
@ -45,6 +48,7 @@ typeset -gA _p9k_skip_token=(
'>>&' '*' '>>&' '*'
'&>>|' '*' '&>>|' '*'
'>>|' '*' '>>|' '*'
'foreach' '\(*\)'
) )
typeset -gA _p9k_redirect=( typeset -gA _p9k_redirect=(
@ -75,10 +79,25 @@ typeset -gA _p9k_term=(
';;' '' ';;' ''
';&' '' ';&' ''
';|' '' ';|' ''
'(' ''
')' '' ')' ''
'{' ''
'}' ''
'()' '' '()' ''
) )
# False positives:
#
# for x (y) z
# {} always {}
#
# Completely broken:
#
# Setup:
# setopt interactive_comments
# alias x='#'
# Punchline:
# x; y
function _p9k_extract_commands() { function _p9k_extract_commands() {
local rcquotes local rcquotes
[[ -o rcquotes ]] && rcquotes=(-o rcquotes) [[ -o rcquotes ]] && rcquotes=(-o rcquotes)
@ -183,6 +202,7 @@ function _p9k_extract_commands() {
fi fi
commands+=${:-${(Q)${~token}}} commands+=${:-${(Q)${~token}}}
[[ $commands[-1] == '(('*'))' ]] && commands[-1]=()
skip='^' skip='^'
done done