back-dollar-quoted-argument: Highlight \uHHHH and \UHHHHHHHH escapes.

This commit is contained in:
Daniel Shahaf 2015-09-25 21:36:20 +00:00
parent 98366ade11
commit 8a43bd2cd9
2 changed files with 10 additions and 4 deletions

View file

@ -312,11 +312,15 @@ _zsh_highlight_main_highlighter_highlight_dollar_string()
case "$arg[$i]" in
"\\") style=$ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]
for (( c = i + 1 ; c < end_pos - start_pos ; c += 1 )); do
[[ "$arg[$c]" != ([0-9xXa-fA-F]) ]] && break
[[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
done
AA=$arg[$i+1,$c-1]
# Matching for HEX and OCT values like \0xA6, \xA6 or \012
if [[ "$AA" =~ "^((x|X)[0-9a-fA-F]{1,2})" || "$AA" =~ "^(0[0-7]{1,3})" ]];then
if [[ "$AA" =~ "^(x|X)[0-9a-fA-F]{1,2}"
|| "$AA" =~ "^0[0-7]{1,3}"
|| "$AA" =~ "^u[0-9a-fA-F]{1,4}"
|| "$AA" =~ "^U[0-9a-fA-F]{1,8}"
]]; then
(( k += $#MATCH ))
(( i += $#MATCH ))
else

View file

@ -29,10 +29,12 @@
# -------------------------------------------------------------------------------------------------
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=$unused_highlight
BUFFER=": \$'foo\xbar'"
BUFFER=": \$'foo\xbar\udeadbeef'"
expected_region_highlight=(
"3 7 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $'foo
"8 11 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \xba
"12 13 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # r'
"12 12 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # r
"13 18 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \dead
"19 23 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # beef'
)