Browse Source

'main': Following up to the last commit, also highlight braced parameter expansions: «${foo}».

pull/550/head
Daniel Shahaf 6 years ago
committed by Matthew Martin
parent
commit
dbdebfaaa5
2 changed files with 8 additions and 2 deletions
  1. +7
    -1
      highlighters/main/main-highlighter.zsh
  2. +1
    -1
      highlighters/main/test-data/path-dollared-word3.zsh

+ 7
- 1
highlighters/main/main-highlighter.zsh View File

@ -509,8 +509,14 @@ _zsh_highlight_main_highlighter_highlight_list()
# parameters that refer to commands, functions, and builtins.
local -a match mbegin mend
local MATCH; integer MBEGIN MEND
local parameter_name
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
parameter_name=${${arg:2}%?}
elif [[ $arg[1] == '$' ]]; then
parameter_name=${arg:1}
fi
if [[ $res == none ]] && (( ${+parameters} )) &&
[[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]] &&
[[ ${parameter_name} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]] &&
(( ${+parameters[(e)${MATCH}]} )) && [[ ${parameters[(e)$MATCH]} != *special* ]]
then
arg=${(P)MATCH}

+ 1
- 1
highlighters/main/test-data/path-dollared-word3.zsh View File

@ -36,5 +36,5 @@ BUFFER='$PWD; ${PWD}'
expected_region_highlight=(
"1 4 path" # $PWD
"5 5 commandseparator" # ;
"7 12 unknown-token" # ${PWD}
"7 12 path" # ${PWD}
)

Loading…
Cancel
Save