Skip to content

Commit b08d508

Browse files
committed
driver: Fix a bug that prevented subsequent, third-party zle-line-pre-redraw hooks from running.
Without this patch, `_zsh_highlight` was invoked by add-zle-hook-widget with `$?` being non-zero (see add-zle-hook-widget:48-52). Since `_zsh_highlight` preserves `$?` from its caller's point of view, add-zle-hook-widget saw a non-zero exit code from `_zsh_highlight` and did not run any the remaining zle-line-pre-redraw hooks. See #579 (comment).
1 parent 8d4c635 commit b08d508

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zsh-syntax-highlighting.zsh

+7-1
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,15 @@ then
350350
_zsh_highlight
351351
}
352352
}
353+
_zsh_highlight__zle-line-pre-redraw() {
354+
# Set $? to 0 for _zsh_highlight. Without this, subsequent
355+
# zle-line-pre-redraw hooks won't run, since add-zle-hook-widget happens to
356+
# call us with $? == 1 in the common case.
357+
true && _zsh_highlight "$@"
358+
}
353359
_zsh_highlight_bind_widgets(){}
354360
if [[ -o zle ]]; then
355-
add-zle-hook-widget zle-line-pre-redraw _zsh_highlight
361+
add-zle-hook-widget zle-line-pre-redraw _zsh_highlight__zle-line-pre-redraw
356362
add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish
357363
fi
358364
else

0 commit comments

Comments
 (0)