From 95d82568d8f9d4ba34eb293b6ce792854a14f110 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sun, 24 Apr 2016 21:07:37 -0500 Subject: [PATCH] 'brackets': Use one-based indexing zsh arrays start at one, and this will make the next commit easier. --- highlighters/brackets/brackets-highlighter.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/highlighters/brackets/brackets-highlighter.zsh b/highlighters/brackets/brackets-highlighter.zsh index 5a2d939..0252fa1 100644 --- a/highlighters/brackets/brackets-highlighter.zsh +++ b/highlighters/brackets/brackets-highlighter.zsh @@ -51,8 +51,8 @@ _zsh_highlight_brackets_highlighter() local -A levelpos lastoflevel matching typepos # Find all brackets and remember which one is matching - for (( pos = 0; pos < buflen; pos++ )) ; do - char="$BUFFER[pos+1]" + for (( pos = 1; pos <= buflen; pos++ )) ; do + char=$BUFFER[pos] case $char in ["([{"]) levelpos[$pos]=$((++level)) @@ -83,7 +83,7 @@ _zsh_highlight_brackets_highlighter() else style=bracket-error fi - _zsh_highlight_add_highlight $pos $((pos + 1)) $style + _zsh_highlight_add_highlight $((pos - 1)) $pos $style done # If cursor is on a bracket, then highlight corresponding bracket, if any