'main': Break out a common pattern. No functional change.

This commit is contained in:
Daniel Shahaf 2018-01-20 15:43:36 +00:00
parent f63f07417d
commit e038a59a83
1 changed files with 3 additions and 2 deletions

View File

@ -1282,10 +1282,11 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
;;
'$' ) style=dollar-double-quoted-argument
# Look for an alphanumeric parameter name.
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
local alphanumeric_parameter_name='[A-Za-z_][A-Za-z0-9_]*|[0-9]+'
if [[ ${arg:$i} =~ ^(${alphanumeric_parameter_name}) ]] ; then
(( k += $#MATCH )) # highlight the parameter name
(( i += $#MATCH )) # skip past it
elif [[ ${arg:$i} =~ ^[{]([A-Za-z_][A-Za-z0-9_]*|[0-9]+)[}] ]] ; then
elif [[ ${arg:$i} =~ ^[{](${alphanumeric_parameter_name})[}] ]] ; then
(( k += $#MATCH )) # highlight the parameter name and braces
(( i += $#MATCH )) # skip past it
elif [[ $arg[i+1] == '$' ]]; then