mirror of
				https://github.com/zsh-users/zsh-syntax-highlighting.git
				synced 2025-10-30 15:56:28 +08:00 
			
		
		
		
	reverse my inital changes to put on branch instead
This commit is contained in:
		
							parent
							
								
									b46769b181
								
							
						
					
					
						commit
						a5a28a194a
					
				| @ -95,7 +95,7 @@ _zsh_highlight_main_add_region_highlight() { | |||||||
| 
 | 
 | ||||||
|   # The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is |   # The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is | ||||||
|   # relative to $BUFFER. |   # relative to $BUFFER. | ||||||
|   (( start -= $#PREBUFFER )) || : |   (( start -= $#PREBUFFER )) | ||||||
|   (( end -= $#PREBUFFER )) |   (( end -= $#PREBUFFER )) | ||||||
| 
 | 
 | ||||||
|   (( end < 0 )) && return # having end<0 would be a bug |   (( end < 0 )) && return # having end<0 would be a bug | ||||||
| @ -146,8 +146,8 @@ _zsh_highlight_main__type() { | |||||||
|       REPLY=none |       REPLY=none | ||||||
|     fi |     fi | ||||||
|   fi |   fi | ||||||
|   if ! (( $+REPLY )); then	# below will frequently trigger ERR trap without || : |   if ! (( $+REPLY )); then | ||||||
|     REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null || :)#*: }" |     REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }" | ||||||
|   fi |   fi | ||||||
|   if (( $+_zsh_highlight_main__command_type_cache )); then |   if (( $+_zsh_highlight_main__command_type_cache )); then | ||||||
|     _zsh_highlight_main__command_type_cache[(e)$1]=$REPLY |     _zsh_highlight_main__command_type_cache[(e)$1]=$REPLY | ||||||
| @ -214,7 +214,7 @@ _zsh_highlight_highlighter_main_paint() | |||||||
|     integer multi_func_def=0 |     integer multi_func_def=0 | ||||||
|   fi |   fi | ||||||
|   emulate -L zsh |   emulate -L zsh | ||||||
|   setopt localoptions extendedglob bareglobqual #xtrace |   setopt localoptions extendedglob bareglobqual | ||||||
| 
 | 
 | ||||||
|   # At the PS3 prompt and in vared, highlight nothing. |   # At the PS3 prompt and in vared, highlight nothing. | ||||||
|   # |   # | ||||||
| @ -384,7 +384,7 @@ _zsh_highlight_highlighter_main_paint() | |||||||
|       else |       else | ||||||
|           integer offset=0 |           integer offset=0 | ||||||
|       fi |       fi | ||||||
|       ((start_pos+=offset)) || : |       ((start_pos+=offset)) | ||||||
|       ((end_pos=$start_pos+${#arg})) |       ((end_pos=$start_pos+${#arg})) | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
| @ -537,9 +537,7 @@ _zsh_highlight_highlighter_main_paint() | |||||||
|                             style=alias |                             style=alias | ||||||
|                             _zsh_highlight_main__resolve_alias $arg |                             _zsh_highlight_main__resolve_alias $arg | ||||||
|                             local alias_target="$REPLY" |                             local alias_target="$REPLY" | ||||||
|                             [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} |                             [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) | ||||||
|                             && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && |  | ||||||
|                                 ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) || : |  | ||||||
|                           fi |                           fi | ||||||
|                         } |                         } | ||||||
|                         ;; |                         ;; | ||||||
| @ -686,7 +684,7 @@ _zsh_highlight_highlighter_main_paint() | |||||||
|     fi |     fi | ||||||
|     if ! (( already_added )); then |     if ! (( already_added )); then | ||||||
|       _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style |       _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style | ||||||
|       [[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators || : |       [[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators | ||||||
|     fi |     fi | ||||||
|     if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then |     if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then | ||||||
|       if [[ $arg == ';' ]] && $in_array_assignment; then |       if [[ $arg == ';' ]] && $in_array_assignment; then | ||||||
|  | |||||||
| @ -109,11 +109,8 @@ _zsh_highlight() | |||||||
|     return $ret |     return $ret | ||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
| # Did a couple of tweaks to highlighters/main/main-highlighter.zsh |   setopt localoptions warncreateglobal | ||||||
| # to prevent need for following, though there'll surely be other areas. |   setopt localoptions noksharrays | ||||||
| # setopt localtraps |  | ||||||
| # unfunction TRAPZERR |  | ||||||
|   setopt localoptions noksharrays warncreateglobal |  | ||||||
|   local REPLY # don't leak $REPLY into global scope |   local REPLY # don't leak $REPLY into global scope | ||||||
| 
 | 
 | ||||||
|   # Do not highlight if there are more than 300 chars in the buffer. It's most |   # Do not highlight if there are more than 300 chars in the buffer. It's most | ||||||
| @ -216,8 +213,7 @@ _zsh_highlight_apply_zle_highlight() { | |||||||
|   local entry="$1" default="$2" |   local entry="$1" default="$2" | ||||||
|   integer first="$3" second="$4" |   integer first="$3" second="$4" | ||||||
| 
 | 
 | ||||||
|   setopt localoptions unset	# seems to be the accessing the array entry |   setopt localoptions unset	# Is it bug or feature that nounset will often abort this function? | ||||||
| # rather than ${entry-} that aborts otherwise |  | ||||||
| 
 | 
 | ||||||
|   # read the relevant entry from zle_highlight |   # read the relevant entry from zle_highlight | ||||||
|   local region="${zle_highlight[(r)${entry}:*]}" |   local region="${zle_highlight[(r)${entry}:*]}" | ||||||
| @ -402,7 +398,7 @@ _zsh_highlight_load_highlighters() | |||||||
|   for highlighter_dir ($1/*/); do |   for highlighter_dir ($1/*/); do | ||||||
|     highlighter="${highlighter_dir:t}" |     highlighter="${highlighter_dir:t}" | ||||||
|     [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] && |     [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] && | ||||||
|       source "$highlighter_dir/${highlighter}-highlighter.zsh" |       . "$highlighter_dir/${highlighter}-highlighter.zsh" | ||||||
|     if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null && |     if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null && | ||||||
|        type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null; |        type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null; | ||||||
|     then |     then | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Paul Ackersviller
						Paul Ackersviller