diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index be1d0a9..d7f04d2 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -167,18 +167,35 @@ _zsh_highlight_main_highlighter_check_path() _zsh_highlight_main_highlighter_highlight_string() { setopt localoptions noksharrays - local i j k style + local i j k style varflag # Starting quote is at 1, so start parsing at offset 2 in the string. for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) (( k = j + 1 )) case "$arg[$i]" in - '$') style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument];; - "\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument] - (( k += 1 )) # Color following char too. - (( i += 1 )) # Skip parsing the escaped char. + '$' ) style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument] + (( varflag = 1)) ;; - *) continue;; + "\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument] + for (( c = i + 1 ; c < end_pos - start_pos ; c += 1 )); do + [[ "$arg[$c]" != ([0-9,xX,a-f,A-F]) ]] && break + done + AA=$arg[$i+1,$c-1] + if [[ "$AA" =~ "^(0*(x|X)[0-9,a-f,A-F]{1,2})" || "$AA" =~ "^(0[0-7]{1,3})" ]];then + (( k += $#MATCH )) + (( i += $#MATCH )) + else + (( k += 1 )) # Color following char too. + (( i += 1 )) # Skip parsing the escaped char. + fi + (( varflag = 0 )) + ;; + ([^a-zA-Z0-9_])) + (( varflag = 0 )) + continue + ;; + *) [[ $varflag -eq 0 ]] && continue ;; + esac region_highlight+=("$j $k $style") done