|
49 | 49 | : ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
|
50 | 50 | : ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
|
51 | 51 | : ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
|
| 52 | +: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan} |
52 | 53 | : ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
53 | 54 | : ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
|
54 | 55 | : ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
@@ -214,6 +215,11 @@ _zsh_highlight_highlighter_main_paint()
|
214 | 215 | else
|
215 | 216 | integer path_dirs_was_set=0
|
216 | 217 | fi
|
| 218 | + if [[ -o rc_quotes ]]; then |
| 219 | + integer rc_quotes=1 |
| 220 | + else |
| 221 | + integer rc_quotes=0 |
| 222 | + fi |
217 | 223 | if [[ -o multi_func_def ]]; then
|
218 | 224 | integer multi_func_def=1
|
219 | 225 | else
|
@@ -677,7 +683,9 @@ _zsh_highlight_highlighter_main_paint()
|
677 | 683 | ;|
|
678 | 684 | '--'*) style=double-hyphen-option;;
|
679 | 685 | '-'*) style=single-hyphen-option;;
|
680 |
| - "'"*) style=single-quoted-argument;; |
| 686 | + "'"*) _zsh_highlight_main_highlighter_highlight_single_quote 1 |
| 687 | + already_added=1 |
| 688 | + ;; |
681 | 689 | '"'*) _zsh_highlight_main_highlighter_highlight_double_quote
|
682 | 690 | already_added=1
|
683 | 691 | ;;
|
@@ -804,6 +812,28 @@ _zsh_highlight_main_highlighter_check_path()
|
804 | 812 | return 1
|
805 | 813 | }
|
806 | 814 |
|
| 815 | +# Highlight single-quoted strings |
| 816 | +_zsh_highlight_main_highlighter_highlight_single_quote() |
| 817 | +{ |
| 818 | + local arg1=$1 i q=\' |
| 819 | + i=$arg[(ib:arg1+1:)$q] |
| 820 | + |
| 821 | + if (( rc_quotes )); then |
| 822 | + local -a highlights |
| 823 | + while [[ $arg[i+1] == "'" ]]; do |
| 824 | + highlights+=($(( start_pos + i - 1 )) $(( start_pos + ++i )) rc-quote) |
| 825 | + i=$arg[(ib:i+1:)$q] |
| 826 | + done |
| 827 | + |
| 828 | + highlights+=($(( start_pos + $1 - 1 )) $(( start_pos + i )) single-quoted-argument $highlights) |
| 829 | + _zsh_highlight_main_add_region_highlights $highlights |
| 830 | + else |
| 831 | + _zsh_highlight_main_add_region_highlight $(( start_pos + $1 - 1)) $(( start_pos + i )) single-quoted-argument |
| 832 | + fi |
| 833 | + |
| 834 | + REPLY=$i |
| 835 | +} |
| 836 | + |
807 | 837 | # Highlight special chars inside double-quoted strings
|
808 | 838 | _zsh_highlight_main_highlighter_highlight_double_quote()
|
809 | 839 | {
|
|
0 commit comments