|
46 | 46 | : ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
|
47 | 47 | : ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
|
48 | 48 | : ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
|
| 49 | +: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan} |
49 | 50 | : ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
|
50 | 51 | : ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
|
51 | 52 | : ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
|
@@ -670,7 +671,9 @@ _zsh_highlight_highlighter_main_paint()
|
670 | 671 | ;|
|
671 | 672 | '--'*) style=double-hyphen-option;;
|
672 | 673 | '-'*) style=single-hyphen-option;;
|
673 |
| - "'"*) style=single-quoted-argument;; |
| 674 | + "'"*) _zsh_highlight_main_highlighter_highlight_single_quote 1 |
| 675 | + already_added=1 |
| 676 | + ;; |
674 | 677 | '"'*) _zsh_highlight_main_highlighter_highlight_double_quote
|
675 | 678 | already_added=1
|
676 | 679 | ;;
|
@@ -797,6 +800,25 @@ _zsh_highlight_main_highlighter_check_path()
|
797 | 800 | return 1
|
798 | 801 | }
|
799 | 802 |
|
| 803 | +# Highlight single-quoted strings |
| 804 | +_zsh_highlight_main_highlighter_highlight_single_quote() |
| 805 | +{ |
| 806 | + local arg1=$1 i q=\' |
| 807 | + local -a highlights |
| 808 | + i=$arg[(ib:arg1+1:)$q] |
| 809 | + |
| 810 | + if [[ $useroptions[rcquotes] == on ]]; then |
| 811 | + while [[ $arg[i+1] == "'" ]]; do |
| 812 | + highlights+=($(( start_pos + i - 1 )) $(( start_pos + ++i )) rc-quote) |
| 813 | + i=$arg[(ib:i+1:)$q] |
| 814 | + done |
| 815 | + fi |
| 816 | + |
| 817 | + highlights+=($(( start_pos + $1 - 1 )) $(( start_pos + i )) single-quoted-argument $highlights) |
| 818 | + _zsh_highlight_main_add_region_highlights $highlights |
| 819 | + REPLY=$i |
| 820 | +} |
| 821 | + |
800 | 822 | # Highlight special chars inside double-quoted strings
|
801 | 823 | _zsh_highlight_main_highlighter_highlight_double_quote()
|
802 | 824 | {
|
|
0 commit comments