main: Recursively expand aliases
This commit is contained in:
		
							parent
							
								
									e1ecf950e2
								
							
						
					
					
						commit
						57386f30ae
					
				|  | @ -500,26 +500,37 @@ _zsh_highlight_main_highlighter_highlight_list() | ||||||
| 
 | 
 | ||||||
|     if [[ $this_word == *:start:* ]] && ! (( in_redirection )); then |     if [[ $this_word == *:start:* ]] && ! (( in_redirection )); then | ||||||
|       # Expand aliases. |       # Expand aliases. | ||||||
|       # TODO: this should be done iteratively, e.g., 'alias x=y y=z z=w\n x' |       # TODO: the entire 'alias' branch of the 'case' statement should | ||||||
|       #       And then the entire 'alias' branch of the 'case' statement should |  | ||||||
|       #       be done here. |       #       be done here. | ||||||
|       _zsh_highlight_main__type "$arg" |       _zsh_highlight_main__type "$arg" | ||||||
|       local res="$REPLY" |       local res="$REPLY" | ||||||
|       if [[ $res == "alias" ]]; then |       if [[ $res == "alias" ]]; then | ||||||
|         _zsh_highlight_main__resolve_alias $arg |  | ||||||
|         () { |         () { | ||||||
|           # Use a temporary array to ensure the subscript is interpreted as |           local -A seen_arg | ||||||
|           # an array subscript, not as a scalar subscript |           while [[ $REPLY == alias ]]; do | ||||||
|           local -a reply |             seen_arg[$arg]=1 | ||||||
|           # TODO: the ${interactive_comments+set} path needs to skip comments; see test-data/alias-comment1.zsh |             _zsh_highlight_main__resolve_alias $arg | ||||||
|           reply=( ${interactive_comments-${(z)REPLY}} |             # Use a temporary array to ensure the subscript is interpreted as | ||||||
|                   ${interactive_comments+${(zZ+c+)REPLY}} ) |             # an array subscript, not as a scalar subscript | ||||||
|           arg=$reply[1] |             local -a reply | ||||||
|  |             # TODO: the ${interactive_comments+set} path needs to skip comments; see test-data/alias-comment1.zsh | ||||||
|  |             reply=( ${interactive_comments-${(z)REPLY}} | ||||||
|  |                     ${interactive_comments+${(zZ+c+)REPLY}} ) | ||||||
|  |             # Avoid looping forever on alias a=b b=c c=b, but allow alias foo='foo bar' | ||||||
|  |             [[ $arg == $reply[1] ]] && break | ||||||
|  |             arg=$reply[1] | ||||||
|  |             if (( $+seen_arg[$arg] )); then | ||||||
|  |               res=none | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             _zsh_highlight_main__type "$arg" | ||||||
|  |           done | ||||||
|         } |         } | ||||||
|       fi |         _zsh_highlight_main_highlighter_expand_path $arg | ||||||
|       _zsh_highlight_main_highlighter_expand_path $arg |         arg=$REPLY | ||||||
|       arg=$REPLY |       else | ||||||
|       if [[ $res != alias ]]; then |         _zsh_highlight_main_highlighter_expand_path $arg | ||||||
|  |         arg=$REPLY | ||||||
|         _zsh_highlight_main__type "$arg" |         _zsh_highlight_main__type "$arg" | ||||||
|         res="$REPLY" |         res="$REPLY" | ||||||
|       fi |       fi | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue