From 6663c5647dd05e9edd7647bf4f6deab4918b26a8 Mon Sep 17 00:00:00 2001 From: Takeshi Banse Date: Sun, 16 Jan 2011 14:12:33 +0900 Subject: [PATCH] Make bracket match a function. Append it to ZSH_HIGHLIGHT_FUNCTIONS. Signed-off-by: Takeshi Banse --- zsh-syntax-highlighting.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 1ebaf13..95b8ca5 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -109,6 +109,7 @@ _zsh_highlight-string() { # Functions to be called in _zsh_highlight-zle-buffer. ZSH_HIGHLIGHT_FUNCTIONS=( _zsh_main-highlight + _zsh_highlight-bracket-match ) # Recolorize the current ZLE buffer. @@ -123,9 +124,8 @@ _zsh_highlight-zle-buffer() { _zsh_main-highlight() { # Avoid doing the same work over and over - [[ ${ZSH_PRIOR_HIGHLIGHTED_BUFFER:-} == $BUFFER ]] && [[ ${#region_highlight} -gt 0 ]] && (( ZSH_PRIOR_CURSOR == CURSOR )) && return + [[ ${ZSH_PRIOR_HIGHLIGHTED_BUFFER:-} == $BUFFER ]] && [[ ${#region_highlight} -gt 0 ]] && return ZSH_PRIOR_HIGHLIGHTED_BUFFER=$BUFFER - ZSH_PRIOR_CURSOR=$CURSOR setopt localoptions extendedglob bareglobqual local new_expression=true @@ -189,6 +189,11 @@ _zsh_main-highlight() { start_pos=$end_pos done +} + +_zsh_highlight-bracket-match() { + (( ZSH_PRIOR_CURSOR == CURSOR )) && return + ZSH_PRIOR_CURSOR=$CURSOR # Bracket matching bracket_color_size=${#ZSH_HIGHLIGHT_MATCHING_BRACKETS_STYLES} if ((bracket_color_size > 0)); then