Skip to content

Commit

Permalink
use zle-line-pre-redraw hook if available
Browse files Browse the repository at this point in the history
  • Loading branch information
m0vie committed Mar 28, 2016
1 parent bc7f8ea commit 88e0d5b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions zsh-syntax-highlighting.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,16 @@ _zsh_highlight_load_highlighters()
# Setup
# -------------------------------------------------------------------------------------------------

# Try binding widgets.
_zsh_highlight_bind_widgets || {
echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2
return 1
}
# Use zle-line-pre-redraw if available. Otherwise try binding widgets as fallback.
autoload -Uz is-at-least
if is-at-least 5.2; then
zle -N zle-line-pre-redraw _zsh_highlight
else
_zsh_highlight_bind_widgets || {
echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2
return 1
}
fi

# Resolve highlighters directory location.
_zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || {
Expand Down

0 comments on commit 88e0d5b

Please sign in to comment.