'main': Factor out common logic to after the case/esac.

This commit is contained in:
Daniel Shahaf 2020-01-12 19:04:57 +00:00
parent 8feb06a022
commit 74c7ffc9b5

View file

@ -656,7 +656,6 @@ _zsh_highlight_main_highlighter_highlight_list()
local MATCH; integer MBEGIN MEND
local parameter_name
local -a words
integer elision_is_happening
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
parameter_name=${${arg:2}%?}
elif [[ $arg[1] == '$' ]]; then
@ -670,20 +669,18 @@ _zsh_highlight_main_highlighter_highlight_list()
case ${(tP)MATCH} in
(*array*|*assoc*)
words=( ${(P)MATCH} )
elision_is_happening=$(( $#words == 0 ))
;;
("")
# not set
words=( )
elision_is_happening=1
;;
(*)
# scalar, presumably
words=( ${(P)MATCH} )
elision_is_happening=$(( $#words == 0 ))
;;
esac
if (( elision_is_happening )); then
if (( $#words == 0 )); then
# Parameter elision is happening
(( ++in_redirection ))
_zsh_highlight_main_add_region_highlight $start_pos $end_pos comment
continue