main: Allow for patterned fallbacks
This commit is contained in:
parent
2fd7fbc3c2
commit
8a0ffe1c43
@ -67,9 +67,6 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
integer start=$1 end=$2
|
integer start=$1 end=$2
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
if (( $+argv[2] )); then
|
|
||||||
# Caller specified inheritance explicitly.
|
|
||||||
else
|
|
||||||
# Automate inheritance.
|
# Automate inheritance.
|
||||||
typeset -A fallback_of; fallback_of=(
|
typeset -A fallback_of; fallback_of=(
|
||||||
alias arg0
|
alias arg0
|
||||||
@ -79,6 +76,7 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
command arg0
|
command arg0
|
||||||
precommand arg0
|
precommand arg0
|
||||||
hashed-command arg0
|
hashed-command arg0
|
||||||
|
arg0_\* arg0
|
||||||
|
|
||||||
path_prefix path
|
path_prefix path
|
||||||
# The path separator fallback won't ever be used, due to the optimisation
|
# The path separator fallback won't ever be used, due to the optimisation
|
||||||
@ -92,12 +90,11 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
back-quoted-argument{-unclosed,}
|
back-quoted-argument{-unclosed,}
|
||||||
)
|
)
|
||||||
local needle=$1 value
|
local needle=$1 value
|
||||||
while [[ -n ${value::=$fallback_of[$needle]} ]]; do
|
while [[ -n ${value::=$fallback_of[(k)$needle]} ]]; do
|
||||||
unset "fallback_of[$needle]" # paranoia against infinite loops
|
unset "fallback_of[$needle]" # paranoia against infinite loops
|
||||||
argv+=($value)
|
argv+=($value)
|
||||||
needle=$value
|
needle=$value
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
|
# The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
|
||||||
# relative to $BUFFER.
|
# relative to $BUFFER.
|
||||||
@ -640,7 +637,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res arg0
|
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
|
||||||
already_added=1
|
already_added=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user