File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 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()
4747_zsh_highlight_highlighter_brackets_paint ()
4848{
4949 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
5151 local -A levelpos lastoflevel matching
5252
5353 # Find all brackets and remember which one is matching
5454 pos=0
55+ escaped_state=0
5556 for char in ${(s..)BUFFER} ; do
5657 (( ++ pos ))
58+ if [[ $char = " \\ " ]]; then
59+ (( escaped_state = ! escaped_state ))
60+ continue
61+ fi
5762 case $char in
5863 [" ([{" ])
59- levelpos[$pos ]=$(( ++ level))
60- lastoflevel[$level ]=$pos
64+ if (( ! escaped_state )) ; then
65+ levelpos[$pos ]=$(( ++ level))
66+ lastoflevel[$level ]=$pos
67+ fi
6168 ;;
6269 [" )]}" ])
63- if (( level > 0 )) ; then
70+ if (( escaped_state )) ; then
71+ :
72+ elif (( level > 0 )) ; then
6473 matchingpos=$lastoflevel [$level ]
6574 levelpos[$pos ]=$(( level-- ))
6675 if _zsh_highlight_brackets_match $matchingpos $pos ; then
@@ -72,6 +81,7 @@ _zsh_highlight_highlighter_brackets_paint()
7281 fi
7382 ;;
7483 esac
84+ escaped_state=0
7585 done
7686
7787 # Now highlight all found brackets
You can’t perform that action at this time.
0 commit comments