File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -47,20 +47,29 @@ _zsh_highlight_highlighter_brackets_predicate()
47
47
_zsh_highlight_highlighter_brackets_paint ()
48
48
{
49
49
local char style
50
- local -i bracket_color_size=${# ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} buflen=${# BUFFER} level=0 matchingpos pos
50
+ local -i bracket_color_size=${# ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} buflen=${# BUFFER} level=0 matchingpos pos escaped_state
51
51
local -A levelpos lastoflevel matching
52
52
53
53
# Find all brackets and remember which one is matching
54
54
pos=0
55
+ escaped_state=0
55
56
for char in ${(s..)BUFFER} ; do
56
57
(( ++ pos ))
58
+ if [[ $char = " \\ " ]]; then
59
+ (( escaped_state = ! escaped_state ))
60
+ continue
61
+ fi
57
62
case $char in
58
63
[" ([{" ])
59
- levelpos[$pos ]=$(( ++ level))
60
- lastoflevel[$level ]=$pos
64
+ if (( ! escaped_state )) ; then
65
+ levelpos[$pos ]=$(( ++ level))
66
+ lastoflevel[$level ]=$pos
67
+ fi
61
68
;;
62
69
[" )]}" ])
63
- if (( level > 0 )) ; then
70
+ if (( escaped_state )) ; then
71
+ :
72
+ elif (( level > 0 )) ; then
64
73
matchingpos=$lastoflevel [$level ]
65
74
levelpos[$pos ]=$(( level-- ))
66
75
if _zsh_highlight_brackets_match $matchingpos $pos ; then
@@ -72,6 +81,7 @@ _zsh_highlight_highlighter_brackets_paint()
72
81
fi
73
82
;;
74
83
esac
84
+ escaped_state=0
75
85
done
76
86
77
87
# Now highlight all found brackets
You can’t perform that action at this time.
0 commit comments