Skip to content

Commit 88e0d5b

Browse files
committed
use zle-line-pre-redraw hook if available
1 parent bc7f8ea commit 88e0d5b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

zsh-syntax-highlighting.zsh

+10-5
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,16 @@ _zsh_highlight_load_highlighters()
281281
# Setup
282282
# -------------------------------------------------------------------------------------------------
283283

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

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

0 commit comments

Comments
 (0)