'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
Fixes #231. Fixes #330.
This commit is contained in:
		
							parent
							
								
									fccf92402b
								
							
						
					
					
						commit
						7fb6f99791
					
				|  | @ -273,6 +273,7 @@ _zsh_highlight_main_highlighter() | ||||||
|     # which add the entry early so escape sequences within the string override |     # which add the entry early so escape sequences within the string override | ||||||
|     # the string's color. |     # the string's color. | ||||||
|     integer already_added=0 |     integer already_added=0 | ||||||
|  |     style=unknown-token | ||||||
|     if [[ $this_word == *':start:'* ]]; then |     if [[ $this_word == *':start:'* ]]; then | ||||||
|       in_array_assignment=false |       in_array_assignment=false | ||||||
|       if [[ $arg == 'noglob' ]]; then |       if [[ $arg == 'noglob' ]]; then | ||||||
|  | @ -468,12 +469,16 @@ _zsh_highlight_main_highlighter() | ||||||
|                         ;; |                         ;; | ||||||
|       esac |       esac | ||||||
|      fi |      fi | ||||||
|     else # $arg is a non-command word |    fi | ||||||
|  |    if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath | ||||||
|  |       { (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] } | ||||||
|  |    then # $arg is a non-command word | ||||||
|       case $arg in |       case $arg in | ||||||
|         $'\x29') # subshell or end of array assignment |         $'\x29') # subshell or end of array assignment | ||||||
|                  if $in_array_assignment; then |                  if $in_array_assignment; then | ||||||
|                    style=assign |                    style=assign | ||||||
|                    in_array_assignment=false |                    in_array_assignment=false | ||||||
|  |                    next_word+=':start:' | ||||||
|                  else |                  else | ||||||
|                    style=reserved-word |                    style=reserved-word | ||||||
|                  fi;; |                  fi;; | ||||||
|  |  | ||||||
|  | @ -32,5 +32,5 @@ BUFFER='A=(hello world) ls' | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1 3 assign" # A=( |   "1 3 assign" # A=( | ||||||
|   "15 15 assign" # ) |   "15 15 assign" # ) | ||||||
|   "17 18 command 'issue #330'" # ls |   "17 18 command" # ls | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -32,5 +32,5 @@ BUFFER='A=(hello world) b=42' | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1 3 assign" # A=( |   "1 3 assign" # A=( | ||||||
|   "15 15 assign" # ) |   "15 15 assign" # ) | ||||||
|   "17 20 assign 'issue #330'" # b=42 |   "17 20 assign" # b=42 | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -32,5 +32,5 @@ BUFFER='(A=1)' | ||||||
| expected_region_highlight=( | expected_region_highlight=( | ||||||
|   "1 1 reserved-word" # ( |   "1 1 reserved-word" # ( | ||||||
|   "2 4 assign" # A=1 |   "2 4 assign" # A=1 | ||||||
|   "5 5 reserved-word 'issue #231'" # ) |   "5 5 reserved-word" # ) | ||||||
| ) | ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue