mirror of
https://github.com/zdharma-continuum/fast-syntax-highlighting.git
synced 2026-09-10 07:16:18 -04:00
*highlight: Use patterns instead of regexes
This commit is contained in:
parent
b259daa347
commit
365e51e0e3
|
|
@ -1379,10 +1379,12 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
|
|||
local i j k __style
|
||||
local AA
|
||||
integer c
|
||||
|
||||
# Starting dollar-quote is at 1:2, so __start parsing at offset 3 in the string.
|
||||
for (( i = 3 ; i < _end_pos - _start_pos ; i += 1 )) ; do
|
||||
(( j = i + _start_pos - 1 ))
|
||||
(( k = j + 1 ))
|
||||
|
||||
case ${__arg[$i]} in
|
||||
"\\") __style=${FAST_THEME_NAME}back-dollar-quoted-argument
|
||||
for (( c = i + 1 ; c <= _end_pos - _start_pos ; c += 1 )); do
|
||||
|
|
@ -1390,13 +1392,13 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
|
|||
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-7]{1,3}"
|
||||
|| "$AA" =~ "^u[0-9a-fA-F]{1,4}"
|
||||
|| "$AA" =~ "^U[0-9a-fA-F]{1,8}"
|
||||
if [[ "$AA" == (#m)(#s)(x|X)[0-9a-fA-F](#c1,2)
|
||||
|| "$AA" == (#m)(#s)[0-7](#c1,3)
|
||||
|| "$AA" == (#m)(#s)u[0-9a-fA-F](#c1,4)
|
||||
|| "$AA" == (#m)(#s)U[0-9a-fA-F](#c1,8)
|
||||
]]; then
|
||||
(( k += $#MATCH ))
|
||||
(( i += $#MATCH ))
|
||||
(( k += MEND ))
|
||||
(( i += MEND ))
|
||||
else
|
||||
if (( __asize > i+1 )) && [[ $__arg[i+1] == [xXuU] ]]; then
|
||||
# \x not followed by hex digits is probably an error
|
||||
|
|
|
|||
Loading…
Reference in a new issue