Fix issue #228, "Support the PATH_DIRS option".
This commit is contained in:
		
							parent
							
								
									a636527f70
								
							
						
					
					
						commit
						96ee5116b1
					
				|  | @ -83,19 +83,33 @@ _zsh_highlight_main_add_region_highlight() { | ||||||
| # Main syntax highlighting function. | # Main syntax highlighting function. | ||||||
| _zsh_highlight_main_highlighter() | _zsh_highlight_main_highlighter() | ||||||
| { | { | ||||||
|  |   ## Before we even 'emulate -L', we must test a few options that would reset. | ||||||
|   if [[ -o interactive_comments ]]; then |   if [[ -o interactive_comments ]]; then | ||||||
|     local interactive_comments= # set to empty |     local interactive_comments= # set to empty | ||||||
|   fi |   fi | ||||||
|  |   if [[ -o path_dirs ]]; then | ||||||
|  |     integer path_dirs_was_set=1 | ||||||
|  |   else | ||||||
|  |     integer path_dirs_was_set=0 | ||||||
|  |   fi | ||||||
|   emulate -L zsh |   emulate -L zsh | ||||||
|   setopt localoptions extendedglob bareglobqual |   setopt localoptions extendedglob bareglobqual | ||||||
|  | 
 | ||||||
|  |   ## Variable declarations and initializations | ||||||
|   local start_pos=0 end_pos highlight_glob=true arg style |   local start_pos=0 end_pos highlight_glob=true arg style | ||||||
|   local in_array_assignment=false # true between 'a=(' and the matching ')' |   local in_array_assignment=false # true between 'a=(' and the matching ')' | ||||||
|   typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR |   typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR | ||||||
|   typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS |   typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS | ||||||
|   typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW |   typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW | ||||||
|  |   local -a options_to_set | ||||||
|   local buf="$PREBUFFER$BUFFER" |   local buf="$PREBUFFER$BUFFER" | ||||||
|   region_highlight=() |   region_highlight=() | ||||||
| 
 | 
 | ||||||
|  |   if (( path_dirs_was_set )); then | ||||||
|  |     options_to_set+=( PATH_DIRS ) | ||||||
|  |   fi | ||||||
|  |   unset path_dirs_was_set | ||||||
|  | 
 | ||||||
|   ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( |   ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( | ||||||
|     '|' '||' ';' '&' '&&' |     '|' '||' ';' '&' '&&' | ||||||
|   ) |   ) | ||||||
|  | @ -239,7 +253,12 @@ _zsh_highlight_main_highlighter() | ||||||
|      else |      else | ||||||
|       _zsh_highlight_main_highlighter_expand_path $arg |       _zsh_highlight_main_highlighter_expand_path $arg | ||||||
|       local expanded_arg="$REPLY" |       local expanded_arg="$REPLY" | ||||||
|       local res="$(LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null)" |       local res="$( | ||||||
|  |         if (( $#options_to_set )); then | ||||||
|  |           setopt $options_to_set; | ||||||
|  |         fi | ||||||
|  |         LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null | ||||||
|  |       )" | ||||||
|       case $res in |       case $res in | ||||||
|         *': reserved')  style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; |         *': reserved')  style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; | ||||||
|         *': suffix alias') |         *': suffix alias') | ||||||
|  |  | ||||||
|  | @ -37,5 +37,5 @@ path+=( "$PWD"/foo ) | ||||||
| BUFFER='bar/testing-issue-228' | BUFFER='bar/testing-issue-228' | ||||||
| 
 | 
 | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1 21 $ZSH_HIGHLIGHT_STYLES[command] 'issue #228'" # bar/testing-issue-228 |   "1 21 $ZSH_HIGHLIGHT_STYLES[command]" # bar/testing-issue-228 | ||||||
| ) | ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue