@@ -103,6 +103,12 @@ _zsh_highlight_main_add_region_highlight() {
103
103
_zsh_highlight_add_highlight $start $end " $@ "
104
104
}
105
105
106
+ _zsh_highlight_main_add_region_highlights () {
107
+ for 1 2 3; do
108
+ _zsh_highlight_main_add_region_highlight $1 $2 $3
109
+ done
110
+ }
111
+
106
112
# Get the type of a command.
107
113
#
108
114
# Uses the zsh/parameter module if available to avoid forks, and a
@@ -665,14 +671,10 @@ _zsh_highlight_highlighter_main_paint()
665
671
' --' * ) style=double-hyphen-option;;
666
672
' -' * ) style=single-hyphen-option;;
667
673
" '" * ) style=single-quoted-argument;;
668
- ' "' * ) style=double-quoted-argument
669
- _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
670
- _zsh_highlight_main_highlighter_highlight_string
674
+ ' "' * ) _zsh_highlight_main_highlighter_highlight_double_quote
671
675
already_added=1
672
676
;;
673
- \$\' * ) style=dollar-quoted-argument
674
- _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
675
- _zsh_highlight_main_highlighter_highlight_dollar_string
677
+ \$\' * ) _zsh_highlight_main_highlighter_highlight_dollar_quote
676
678
already_added=1
677
679
;;
678
680
' `' * ) style=back-quoted-argument;;
@@ -796,12 +798,12 @@ _zsh_highlight_main_highlighter_check_path()
796
798
}
797
799
798
800
# Highlight special chars inside double-quoted strings
799
- _zsh_highlight_main_highlighter_highlight_string ()
801
+ _zsh_highlight_main_highlighter_highlight_double_quote ()
800
802
{
801
- setopt localoptions noksharrays
802
- local -a match mbegin mend
803
+ local -a highlights match mbegin mend
803
804
local MATCH; integer MBEGIN MEND
804
805
local i j k style
806
+
805
807
# Starting quote is at 1, so start parsing at offset 2 in the string.
806
808
for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
807
809
(( j = i + start_pos - 1 ))
@@ -847,19 +849,22 @@ _zsh_highlight_main_highlighter_highlight_string()
847
849
* ) continue ;;
848
850
849
851
esac
850
- _zsh_highlight_main_add_region_highlight $j $k $style
852
+ highlights+=( $j $k $style )
851
853
done
854
+
855
+ highlights=($start_pos $end_pos double-quoted-argument $highlights )
856
+ _zsh_highlight_main_add_region_highlights $highlights
852
857
}
853
858
854
859
# Highlight special chars inside dollar-quoted strings
855
- _zsh_highlight_main_highlighter_highlight_dollar_string ()
860
+ _zsh_highlight_main_highlighter_highlight_dollar_quote ()
856
861
{
857
- setopt localoptions noksharrays
858
- local -a match mbegin mend
862
+ local -a highlights match mbegin mend
859
863
local MATCH; integer MBEGIN MEND
860
864
local i j k style
861
865
local AA
862
866
integer c
867
+
863
868
# Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string.
864
869
for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do
865
870
(( j = i + start_pos - 1 ))
@@ -890,8 +895,11 @@ _zsh_highlight_main_highlighter_highlight_dollar_string()
890
895
* ) continue ;;
891
896
892
897
esac
893
- _zsh_highlight_main_add_region_highlight $j $k $style
898
+ highlights+=( $j $k $style )
894
899
done
900
+
901
+ highlights+=($start_pos $end_pos dollar-quoted-argument $highlights )
902
+ _zsh_highlight_main_add_region_highlights $highlights
895
903
}
896
904
897
905
# Called with a single positional argument.
0 commit comments