From 0a9b347483ae653e95ed7ccb147a0db3644b6384 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 22 Sep 2016 04:10:28 +0000 Subject: [PATCH] driver: Warn just once when a highlighter is missing. The heretofore code warned once per keypress. --- zsh-syntax-highlighting.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index f9d82de..ec01306 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -92,7 +92,11 @@ _zsh_highlight() typeset -ga ${cache_place} # If highlighter needs to be invoked - if "_zsh_highlight_highlighter_${highlighter}_predicate"; then + if ! type "_zsh_highlight_highlighter_${highlighter}_predicate" >&/dev/null; then + echo "zsh-syntax-highlighting: warning: disabling the ${(qq)highlighter} highlighter as it has not been loaded" >&2 + # TODO: use ${(b)} rather than ${(q)} if supported + ZSH_HIGHLIGHT_HIGHLIGHTERS=( ${ZSH_HIGHLIGHT_HIGHLIGHTERS:#${highlighter}} ) + elif "_zsh_highlight_highlighter_${highlighter}_predicate"; then # save a copy, and cleanup region_highlight region_highlight_copy=("${region_highlight[@]}")