Skip to content

Commit

Permalink
Merge pull request #62 from garinger/master
Browse files Browse the repository at this point in the history
Fix for Issue #35 "Unclosed brackets not marked as error"
  • Loading branch information
nicoulaj committed Jul 8, 2011
2 parents 1858be2 + 48c30a8 commit eb749f2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions highlighters/brackets/brackets-highlighter.zsh
Expand Up @@ -46,8 +46,9 @@ _zsh_highlight_brackets_highlighter_predicate()
# Brackets highlighting function.
_zsh_highlight_brackets_highlighter()
{
bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]}
local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]}
if ((bracket_color_size > 0)); then
local c level pos
typeset -A levelpos lastoflevel matching revmatching
((level = 0))
for pos in {1..${#BUFFER}}; do
Expand All @@ -64,15 +65,16 @@ _zsh_highlight_brackets_highlighter()
esac
done
for pos in ${(k)levelpos}; do
level=$levelpos[$pos]
if ((level < 1)); then
if [[ -z $matching[$pos] ]] && [[ -z $revmatching[$pos] ]]; then
region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[bracket-error])
else
region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[bracket-level-$(( (level - 1) % bracket_color_size + 1 ))])
local style=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[$style])
fi
done
((c = CURSOR + 1))
if [[ -n $levelpos[$c] ]]; then
local otherpos
((otherpos = -1))
[[ -n $matching[$c] ]] && otherpos=$matching[$c]
[[ -n $revmatching[$c] ]] && otherpos=$revmatching[$c]
Expand Down

0 comments on commit eb749f2

Please sign in to comment.