'main': Break out a new helper function for readability.
This commit is contained in:
		
							parent
							
								
									f3425e18fe
								
							
						
					
					
						commit
						3a33ac1d20
					
				|  | @ -174,6 +174,17 @@ _zsh_highlight_main__type() { | ||||||
|   return $? |   return $? | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | # Checks whether $1 is something that can be run. | ||||||
|  | # | ||||||
|  | # Return 0 if runnable, 1 if not runnable, 2 if trouble. | ||||||
|  | _zsh_highlight_main__is_runnable() { | ||||||
|  |   if _zsh_highlight_main__type "$1"; then | ||||||
|  |     [[ $REPLY != none ]] | ||||||
|  |   else | ||||||
|  |     return 2 | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
| # Check whether the first argument is a redirection operator token. | # Check whether the first argument is a redirection operator token. | ||||||
| # Report result via the exit code. | # Report result via the exit code. | ||||||
| _zsh_highlight_main__is_redirection() { | _zsh_highlight_main__is_redirection() { | ||||||
|  | @ -586,7 +597,7 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
|      style=reserved-word # de facto a reserved word, although not de jure |      style=reserved-word # de facto a reserved word, although not de jure | ||||||
|      next_word=':start:' |      next_word=':start:' | ||||||
|    elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word |    elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word | ||||||
|      if (( ${+precommand_options[$arg]} )) && { _zsh_highlight_main__type $arg && [[ $REPLY != "none" ]] }; then |      if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then | ||||||
|       style=precommand |       style=precommand | ||||||
|       flags_with_argument=${precommand_options[$arg]%:*} |       flags_with_argument=${precommand_options[$arg]%:*} | ||||||
|       flags_sans_argument=${precommand_options[$arg]#*:} |       flags_sans_argument=${precommand_options[$arg]#*:} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue