Skip to content

Commit

Permalink
don't highlight in isearch if ISEARCH_ACTIVE is unsupported
Browse files Browse the repository at this point in the history
Old version of zsh don't expose ISEARCH_ACTIVE. Therefore we are
unable to re-apply zle_highlight on top and it is impossible to
see the underlined area.

Completely disable highlighting in isearch in that case.

To do that, we need to make sure we are actually called when
something changes in isearch.

Trumps zsh-users#257.
  • Loading branch information
m0vie committed Mar 29, 2016
1 parent 65aa834 commit 7fc29b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions zsh-syntax-highlighting.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ _zsh_highlight()
# Store the previous command return code to restore it whatever happens.
local ret=$?

# Do not highlight in isearch if ISEARCH_ACTIVE is unsupported (zsh < 5.3).
if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCH_ACTIVE )); then
region_highlight=()
return $ret
fi

setopt localoptions warncreateglobal
setopt localoptions noksharrays
local REPLY # don't leak $REPLY into global scope
Expand Down Expand Up @@ -315,6 +321,10 @@ _zsh_highlight_bind_widgets || {
# E.g. remove cursor imprint, don't highlight partial paths, ...
_zsh_highlight_set_or_wrap_special_zle_widget zle-line-finish

# Always wrap special zle-isearch-update widget to be notified of updates in isearch
_zsh_highlight_set_or_wrap_special_zle_widget zle-isearch-update


# Resolve highlighters directory location.
_zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || {
echo 'zsh-syntax-highlighting: failed loading highlighters, exiting.' >&2
Expand Down

0 comments on commit 7fc29b5

Please sign in to comment.