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' '\(*\)'
)
typeset -gA _p9k_precomands=(
typeset -gA __p9k_pb_precommand=(
'-' ''
'builtin' ''
'command' ''
@ -53,7 +53,7 @@ typeset -gA _p9k_precomands=(
'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'
'(' '\)'
'()' ''
)
# False positives:
@ -132,13 +132,15 @@ typeset -gA _p9k_skip_arg=(
# Punchline:
# x; y
# ---------------
function _p9k_extract_commands() {
#
# More brokenness with non-standard options (ignore_braces, ignore_close_braces, etc.).
function _p9k_parse_buffer() {
local rcquotes
[[ -o rcquotes ]] && rcquotes=(-o 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 var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
@ -192,10 +194,10 @@ function _p9k_extract_commands() {
case $state in
t|p*)
if (( $+_p9k_term[$token] )); then
skip=$_p9k_skip_arg[$token]
if (( $+__p9k_pb_term[$token] )); then
skip=$__p9k_pb_term_skip[$token]
state=${skip:+s}
[[ $token == '()' ]] || _p9k_commands+=($commands)
[[ $token == '()' ]] || _p9k_buffer_commands+=($commands)
commands=()
continue
elif [[ $state == t ]]; then
@ -220,7 +222,7 @@ function _p9k_extract_commands() {
continue
fi
if (( $+_p9k_redirect[${token#<0-255>}] )); then
if (( $+__p9k_pb_redirect[${token#<0-255>}] )); then
state+=r
continue
fi
@ -236,8 +238,8 @@ function _p9k_extract_commands() {
case $state in
'')
if (( $+_p9k_skip_token[$token] )); then
skip=$_p9k_skip_token[$token]
if (( $+__p9k_pb_cmd_skip[$token] )); then
skip=$__p9k_pb_cmd_skip[$token]
state=${skip:+s}
continue
fi
@ -267,15 +269,15 @@ function _p9k_extract_commands() {
esac
commands+=$token
if (( $+_p9k_precomands[$commands[-1]] )); then
if (( $+__p9k_pb_precommand[$commands[-1]] )); then
state=p
skip=$_p9k_precomands[$commands[-1]]
skip=$__p9k_pb_precommand[$commands[-1]]
else
state=t
fi
done
}
_p9k_commands+=($commands)
_p9k_commands=(${(u)_p9k_commands:#('(('*'))'|'`'*'`'|'$'*)})
_p9k_buffer_commands+=($commands)
_p9k_buffer_commands=(${(u)_p9k_buffer_commands:#('(('*'))'|'`'*'`'|'$'*)})
}

Loading…
Cancel
Save