Skip to content

Commit e3b32de

Browse files
committed
use zle-line-pre-redraw hook if available
Fixes #245.
1 parent 0b3a4c8 commit e3b32de

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
@@ -308,11 +308,16 @@ _zsh_highlight_load_highlighters()
308308
# Setup
309309
# -------------------------------------------------------------------------------------------------
310310

311-
# Try binding widgets.
312-
_zsh_highlight_bind_widgets || {
313-
echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2
314-
return 1
315-
}
311+
# Use zle-line-pre-redraw if available. Otherwise try binding widgets as fallback.
312+
autoload -Uz is-at-least
313+
if is-at-least 5.2; then
314+
_zsh_highlight_set_or_wrap_special_zle_widget zle-line-pre-redraw
315+
else
316+
_zsh_highlight_bind_widgets || {
317+
echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2
318+
return 1
319+
}
320+
fi
316321

317322
# Always wrap special zle-line-finish widget. This is needed to decide if the
318323
# current line ends and special highlighting logic needs to be applied.

0 commit comments

Comments
 (0)