diff --git a/docs/highlighters/main.md b/docs/highlighters/main.md index 71c8ec3..af7815e 100644 --- a/docs/highlighters/main.md +++ b/docs/highlighters/main.md @@ -33,6 +33,7 @@ This highlighter defines the following styles: * `globbing` - globbing expressions (`*.txt`) * `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`) * `command-substitution` - command substitutions (`$(echo foo)`) +* `process-substitution` - process substitutions (`<(echo foo)`) * `single-hyphen-option` - single-hyphen options (`-o`) * `double-hyphen-option` - double-hyphen options (`--option`) * `back-quoted-argument` - backtick command substitution (`` `foo` ``) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index b1d614c..5015d65 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -41,6 +41,7 @@ : ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[command-substitution]:=fg=magenta} +: ${ZSH_HIGHLIGHT_STYLES[process-substitution]:=fg=magenta} : ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none} : ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none} : ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none} @@ -896,6 +897,16 @@ _zsh_highlight_main_highlighter_highlight_argument() if [[ $arg[i+1] == [*@#?$!-] ]]; then (( i += 1 )) fi;; + [\<\>]) + if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren + start=$i + (( i += 2 )) + _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos] + (( i += REPLY )) + highlights+=($(( start_pos + start - 1)) $(( start_pos + i )) process-substitution $reply) + continue + fi + ;| *) if $highlight_glob && [[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing) diff --git a/highlighters/main/test-data/redirection2.zsh b/highlighters/main/test-data/redirection2.zsh index 1a1588d..7a8c6e1 100644 --- a/highlighters/main/test-data/redirection2.zsh +++ b/highlighters/main/test-data/redirection2.zsh @@ -31,7 +31,9 @@ BUFFER='ls >(wc) | nl' expected_region_highlight=( "1 2 command" # ls - "4 8 process-substitution 'issue #494'" # >(wc) + "4 8 default" # >(wc) + "4 8 process-substitution" # >(wc) + "6 7 command" # wc "10 10 commandseparator" # | "12 13 command" # nl )