pull/436/head
romkatv 5 years ago
parent df4b33c699
commit dd437267cd

@ -1,4 +1,4 @@
typeset -gA _p9k_skip_token=( typeset -gA __p9k_pb_cmd_skip=(
'}' '' '}' ''
'|' '' '|' ''
'||' '' '||' ''
@ -37,7 +37,7 @@ typeset -gA _p9k_skip_token=(
'foreach' '\(*\)' 'foreach' '\(*\)'
) )
typeset -gA _p9k_precomands=( typeset -gA __p9k_pb_precommand=(
'-' '' '-' ''
'builtin' '' 'builtin' ''
'command' '' 'command' ''
@ -53,7 +53,7 @@ typeset -gA _p9k_precomands=(
'sudo' '-[^aghpuUCcrtT]#[aghpuUCcrtT]|--(close-from|group|host|prompt|role|type|other-user|command-timeout|user)' 'sudo' '-[^aghpuUCcrtT]#[aghpuUCcrtT]|--(close-from|group|host|prompt|role|type|other-user|command-timeout|user)'
) )
typeset -gA _p9k_redirect=( typeset -gA __p9k_pb_redirect=(
'&>' '' '&>' ''
'>' '' '>' ''
'>&' '' '>&' ''
@ -70,7 +70,7 @@ typeset -gA _p9k_redirect=(
'<<<' '' '<<<' ''
) )
typeset -gA _p9k_term=( typeset -gA __p9k_pb_term=(
'|' '' '|' ''
'||' '' '||' ''
';' '' ';' ''
@ -89,12 +89,12 @@ typeset -gA _p9k_term=(
'()' '' '()' ''
) )
typeset -gA _p9k_skip_arg=( typeset -gA __p9k_pb_term_skip=(
'()' ''
'(' '\)'
';;' '\)|esac' ';;' '\)|esac'
';&' '\)|esac' ';&' '\)|esac'
';|' '\)|esac' ';|' '\)|esac'
'(' '\)'
'()' ''
) )
# False positives: # False positives:
@ -132,13 +132,15 @@ typeset -gA _p9k_skip_arg=(
# Punchline: # Punchline:
# x; y # x; y
# --------------- # ---------------
function _p9k_extract_commands() { #
# More brokenness with non-standard options (ignore_braces, ignore_close_braces, etc.).
function _p9k_parse_buffer() {
local rcquotes local rcquotes
[[ -o rcquotes ]] && rcquotes=(-o rcquotes) [[ -o rcquotes ]] && rcquotes=(-o rcquotes)
emulate -L zsh -o extended_glob -o no_nomatch $rcquotes emulate -L zsh -o extended_glob -o no_nomatch $rcquotes
typeset -ga _p9k_commands=() typeset -ga _p9k_buffer_commands=()
local -r id='(<->|[[:alpha:]_][[:IDENT:]]#)' local -r id='(<->|[[:alpha:]_][[:IDENT:]]#)'
local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\"" local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
@ -192,10 +194,10 @@ function _p9k_extract_commands() {
case $state in case $state in
t|p*) t|p*)
if (( $+_p9k_term[$token] )); then if (( $+__p9k_pb_term[$token] )); then
skip=$_p9k_skip_arg[$token] skip=$__p9k_pb_term_skip[$token]
state=${skip:+s} state=${skip:+s}
[[ $token == '()' ]] || _p9k_commands+=($commands) [[ $token == '()' ]] || _p9k_buffer_commands+=($commands)
commands=() commands=()
continue continue
elif [[ $state == t ]]; then elif [[ $state == t ]]; then
@ -220,7 +222,7 @@ function _p9k_extract_commands() {
continue continue
fi fi
if (( $+_p9k_redirect[${token#<0-255>}] )); then if (( $+__p9k_pb_redirect[${token#<0-255>}] )); then
state+=r state+=r
continue continue
fi fi
@ -236,8 +238,8 @@ function _p9k_extract_commands() {
case $state in case $state in
'') '')
if (( $+_p9k_skip_token[$token] )); then if (( $+__p9k_pb_cmd_skip[$token] )); then
skip=$_p9k_skip_token[$token] skip=$__p9k_pb_cmd_skip[$token]
state=${skip:+s} state=${skip:+s}
continue continue
fi fi
@ -267,15 +269,15 @@ function _p9k_extract_commands() {
esac esac
commands+=$token commands+=$token
if (( $+_p9k_precomands[$commands[-1]] )); then if (( $+__p9k_pb_precommand[$commands[-1]] )); then
state=p state=p
skip=$_p9k_precomands[$commands[-1]] skip=$__p9k_pb_precommand[$commands[-1]]
else else
state=t state=t
fi fi
done done
} }
_p9k_commands+=($commands) _p9k_buffer_commands+=($commands)
_p9k_commands=(${(u)_p9k_commands:#('(('*'))'|'`'*'`'|'$'*)}) _p9k_buffer_commands=(${(u)_p9k_buffer_commands:#('(('*'))'|'`'*'`'|'$'*)})
} }

Loading…
Cancel
Save