*highlight: Use $REPLY, don't create additional variables

This commit is contained in:
Sebastian Gniazdowski 2016-10-15 13:29:20 +02:00
parent 05cb4c6073
commit 8acdd8bd5b

View file

@ -386,9 +386,7 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
next_word+=':start:'
else
-hsmw-highlight-expand-path $arg
local expanded_arg="$REPLY"
-hsmw-highlight-main-type ${expanded_arg}
local res="$REPLY"
-hsmw-highlight-main-type $REPLY
() {
# Special-case: command word is '$foo', like that, without braces or anything.
#
@ -397,15 +395,14 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
# incorrectness is outweighed by the usability improvement of permitting the use of
# parameters that refer to commands, functions, and builtins.
local MATCH; integer MBEGIN MEND
if [[ $res == none ]] && (( ${+parameters} )) &&
if [[ $REPLY == none ]] && (( ${+parameters} )) &&
[[ ${arg[1]} == \$ ]] && [[ ${arg:1} = (#m)([[:alpha:]_][[:alnum:]_]#|[[:digit:]]##) ]] &&
(( ${+parameters[${MATCH}]} ))
then
-hsmw-highlight-main-type ${(P)MATCH}
res=$REPLY
fi
}
case $res in
case $REPLY in
reserved) # reserved word
style=reserved-word
if [[ $arg == $'\x7b' ]]; then
@ -502,7 +499,7 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
fi
fi
;;
*) -hsmw-add-highlight $start_pos $end_pos commandtypefromthefuture-$res
*) -hsmw-add-highlight $start_pos $end_pos commandtypefromthefuture-$REPLY
already_added=1
;;
esac