From f1eb5aeef7cf86d69e31deeb915522fef55bfb51 Mon Sep 17 00:00:00 2001 From: garinger Date: Tue, 12 Jul 2011 08:11:21 -0700 Subject: [PATCH] skip all brackets inside quotes (" and ') --- highlighters/brackets/brackets-highlighter.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/highlighters/brackets/brackets-highlighter.zsh b/highlighters/brackets/brackets-highlighter.zsh index 675b4cd..91d114c 100644 --- a/highlighters/brackets/brackets-highlighter.zsh +++ b/highlighters/brackets/brackets-highlighter.zsh @@ -49,19 +49,26 @@ _zsh_highlight_brackets_highlighter() local level pos local -A levelpos lastoflevel matching typepos ((level = 0)) - for pos in {1..${#BUFFER}}; do + for ((pos = 1; $pos <= ${#BUFFER}; pos++ )) ; do case $BUFFER[pos] in - "("|"["|"{") + ["([{"]) levelpos[$pos]=$((++level)) lastoflevel[$level]=$pos typepos[$pos]=$BUFFER[$pos] ;; - ")"|"]"|"}") + [")]}"]) matching[$lastoflevel[$level]]=$pos matching[$pos]=$lastoflevel[$level] levelpos[$pos]=$((level--)) typepos[$pos]=$BUFFER[$pos] ;; + ['"'\']) + local temp=$BUFFER[$pos] + while (( $pos < ${#BUFFER} )) ; do + ((++pos)) + [[ $BUFFER[$pos] == $temp ]] && break + done + ;; esac done for pos in ${(k)typepos}; do