mirror of
				https://github.com/zsh-users/zsh-syntax-highlighting.git
				synced 2025-10-30 15:56:28 +08:00 
			
		
		
		
	'main': Following up to the last commit, also highlight braced parameter expansions: «${foo}».
This commit is contained in:
		
							parent
							
								
									40dcbfbcf6
								
							
						
					
					
						commit
						9c8b95171c
					
				@ -469,8 +469,14 @@ _zsh_highlight_highlighter_main_paint()
 | 
				
			|||||||
      # parameters that refer to commands, functions, and builtins.
 | 
					      # parameters that refer to commands, functions, and builtins.
 | 
				
			||||||
      local -a match mbegin mend
 | 
					      local -a match mbegin mend
 | 
				
			||||||
      local MATCH; integer 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} )) &&
 | 
					      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[${MATCH}]} ))
 | 
					         (( ${+parameters[${MATCH}]} ))
 | 
				
			||||||
         then
 | 
					         then
 | 
				
			||||||
        arg=${(P)MATCH}
 | 
					        arg=${(P)MATCH}
 | 
				
			||||||
 | 
				
			|||||||
@ -35,5 +35,5 @@ BUFFER='$PWD; ${PWD}'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
expected_region_highlight=(
 | 
					expected_region_highlight=(
 | 
				
			||||||
  "1 4 path" # $PWD
 | 
					  "1 4 path" # $PWD
 | 
				
			||||||
  "7 12 unknown-token" # ${PWD}
 | 
					  "7 12 path" # ${PWD}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user