This commit is contained in:
Daniel Shahaf 2024-11-22 14:15:04 +00:00 committed by GitHub
commit e567bd07c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 2 deletions

View file

@ -1510,10 +1510,13 @@ _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]+'
# :gs,:s,:F,:W take an argument between delimiters; we don't currently highlight delimiters.
local history_modifiers=':[aAcehlpPqQ&tuxfw]|:gs.|:s.|:F.|:W.'
if [[ ${arg:$i} =~ ^(${alphanumeric_parameter_name})(${history_modifiers})* ]] ; 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})(${history_modifiers})*[}] ]] ; then
(( k += $#MATCH )) # highlight the parameter name and braces
(( i += $#MATCH )) # skip past it
elif [[ $arg[i+1] == '$' ]]; then