From 59cb9a560d3b2acdb21c666d09ff43411c2153a0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 14 Jul 2020 02:13:51 +0000 Subject: [PATCH] driver: Make the redrawhook codepath conditional upon the memo= feature. Fixes #579 (zsh-autosuggestions interoperability). Fixes #735 (ditto). See https://github.com/zsh-users/zsh-syntax-highlighting/issues/579#issuecomment-650126055 See https://github.com/zsh-users/zsh-autosuggestions/issues/529#issuecomment-650481227 --- zsh-syntax-highlighting.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index c2811a0..87ffb6a 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -403,7 +403,17 @@ _zsh_highlight_call_widget() _zsh_highlight } -if _zsh_highlight__function_callable_p add-zle-hook-widget +# Decide whether to use the zle-line-pre-redraw codepath (colloquially known as +# "feature/redrawhook", after the topic branch's name) or the legacy "bind all +# widgets" codepath. +# +# We use the new codepath under two conditions: +# +# 1. If it's available, which we check by testing for add-zle-hook-widget's availability. +# +# 2. If zsh has the memo= feature, which is required for interoperability reasons. +# See issues #579 and #735, and the issues referenced from them. +if (( zsh_highlight__memo_feature )) && _zsh_highlight__function_callable_p add-zle-hook-widget then autoload -U add-zle-hook-widget _zsh_highlight__zle-line-finish() {