From ef41c9232d62e1ae7cf2cadb9ce8a6372341dddf Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 18:56:35 +0000 Subject: [PATCH 01/14] wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650). --- zsh-syntax-highlighting.zsh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 87967b6..2b00a7f 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -42,6 +42,11 @@ if true; then fi fi +integer zsh_highlight_use_redrawhook +if zle -la .match-bracket; then + (( zsh_highlight_use_redrawhook=1 )) +fi + # ------------------------------------------------------------------------------------------------- # Core highlighting update system # ------------------------------------------------------------------------------------------------- @@ -268,6 +273,11 @@ _zsh_highlight_bind_widgets() done } +if (( $zsh_highlight_use_redrawhook )); then + _zsh_highlight_bind_widgets(){} + zle -N zle-line-pre-redraw _zsh_highlight +fi + # Load highlighters from directory. # # Arguments: From 98aab2024c284681aa1cdcd5ded6121a90af2c70 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 15 Jun 2016 23:26:23 +0000 Subject: [PATCH 02/14] driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw' This feature will be released in zsh 5.3. Older zsh's will use the existing codepath. --- zsh-syntax-highlighting.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 2b00a7f..a19ec0e 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -43,7 +43,9 @@ if true; then fi integer zsh_highlight_use_redrawhook -if zle -la .match-bracket; then +if autoload -U +X -- add-zle-hook-widget 2>/dev/null; + [[ "${${(@f)"$(which -- add-zle-hook-widget)"}[2]}" != $'\t'$histchars[3]' undefined' ]]; +then (( zsh_highlight_use_redrawhook=1 )) fi @@ -275,7 +277,7 @@ _zsh_highlight_bind_widgets() if (( $zsh_highlight_use_redrawhook )); then _zsh_highlight_bind_widgets(){} - zle -N zle-line-pre-redraw _zsh_highlight + add-zle-hook-widget zle-line-pre-redraw _zsh_highlight fi # Load highlighters from directory. From a7470586a9e8b0f9b100b26a3b103b012a505f70 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 29 Jul 2016 20:32:29 +0000 Subject: [PATCH 03/14] driver: Hook zle-line-finish. Compare issue #288. --- zsh-syntax-highlighting.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index a19ec0e..941982f 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -276,8 +276,19 @@ _zsh_highlight_bind_widgets() } if (( $zsh_highlight_use_redrawhook )); then + _zsh_highlight__zle-line-finish() { + # Reset $WIDGET since the 'main' highlighter depends on it. + # + # A nested function is required to hide zle parameters; see + # "User-defined widgets" in zshall. + () { + local -h +r WIDGET=zle-line-finish + _zsh_highlight "$@" + } + } _zsh_highlight_bind_widgets(){} add-zle-hook-widget zle-line-pre-redraw _zsh_highlight + add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish fi # Load highlighters from directory. From eb506b52b49c3589b20af1d8f360bed4dc228df9 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 24 Aug 2016 22:56:09 +0000 Subject: [PATCH 04/14] driver: Pass zle-line-finish arguments on to _zsh_highlight. (Currently a noop) --- zsh-syntax-highlighting.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 941982f..c8e44ec 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -284,7 +284,7 @@ if (( $zsh_highlight_use_redrawhook )); then () { local -h +r WIDGET=zle-line-finish _zsh_highlight "$@" - } + } "$@" } _zsh_highlight_bind_widgets(){} add-zle-hook-widget zle-line-pre-redraw _zsh_highlight From 487b6bf63d9edf511c06ba2cda15368b1fe404fd Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 5 Sep 2016 04:41:51 +0000 Subject: [PATCH 05/14] changelog: Note the effect of fixing #245/#90 and an alternative. --- changelog.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/changelog.md b/changelog.md index 94cb929..c90e9f3 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,27 @@ up to 952a97dbc99a54bd86141b7a57625e748941a937 + 0.4.1 +# Changes in version 0.5.0 + + +## Incompatible changes: + +- An unsuccessful completion (a ⮀ Tab press that doesn't change the + command line) no longer causes highlighting to be lost. Visual feedback can + alternatively be achieved by setting the `format` zstyle under the `warnings` + tag, for example, + + zstyle ':completion:*:warnings' format '%F{red}No matches%f' + + Refer to the [description of the `format` style in `zshcompsys(1)`] + [zshcompsys-Standard-Styles]. + + (#90, part of #245, XXXXXXXXXXXX) + +[zshcompsys-Standard-Styles]: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Standard-Styles + + + # Changes in version 0.4.1 ## Fixes: From 1f8b1755d91873ce35da9a56cc7f1635a5a10437 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 5 Sep 2016 04:45:05 +0000 Subject: [PATCH 06/14] changelog: Use a more specific link. --- changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index c90e9f3..520cbab 100644 --- a/changelog.md +++ b/changelog.md @@ -16,11 +16,12 @@ up to 952a97dbc99a54bd86141b7a57625e748941a937 + 0.4.1 zstyle ':completion:*:warnings' format '%F{red}No matches%f' Refer to the [description of the `format` style in `zshcompsys(1)`] - [zshcompsys-Standard-Styles]. + [zshcompsys-Standard-Styles-format]. (#90, part of #245, XXXXXXXXXXXX) [zshcompsys-Standard-Styles]: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Standard-Styles +[zshcompsys-Standard-Styles-format]: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#index-format_002c-completion-style From b30e5b593e9cb6c75ce3b463f8ae472e6cfd8e12 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 5 Sep 2016 03:23:08 +0000 Subject: [PATCH 07/14] driver: Use a different way of checking whether add-zle-hook-widget is present. Based on code by Bart Schaefer (reference within). Tested with zsh 5.0.7-5 (debian package) and with 5b4cbcc842c6 (39158, 5.3-to-be of today). --- zsh-syntax-highlighting.zsh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index c8e44ec..5b56b08 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -42,10 +42,37 @@ if true; then fi fi +# This function takes a single argument F and returns True iff F denotes the +# name of a callable function. A function is callable if it is fully defined +# or if it is marked for autoloading and autoloading it at the first call to it +# will succeed. In particular, if a function has been marked for autoloading +# but is not available in $fpath, then this function will return False therefor. +# +# See users/21671 http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=21671 +_zsh_highlight__function_callable_p() { + { # Trenary condition: if the zle/parameter module is available, ... + if (( ${+functions} )); then + # ... then use it to make the decision, ... + if (( ${+functions[$1]} )); then + [[ "$functions[$1]" != *"builtin autoload -X" ]] \ + || + ( unfunction -- "$1" && autoload -U +X -- "$1" 2>/dev/null ) + else + ( autoload -U +X -- "$1" 2>/dev/null ) + fi + else + # ... otherwise, use a fallback approach. + autoload -U +X -- "$1" 2>/dev/null + [[ "${${(@f)"$(which -- "$1")"}[2]}" != $'\t'$histchars[3]' undefined' ]] + fi + } + # Do nothing here! We return the exit code of the if. +} + integer zsh_highlight_use_redrawhook -if autoload -U +X -- add-zle-hook-widget 2>/dev/null; - [[ "${${(@f)"$(which -- add-zle-hook-widget)"}[2]}" != $'\t'$histchars[3]' undefined' ]]; +if _zsh_highlight__function_callable_p add-zle-hook-widget then + autoload -U add-zle-hook-widget (( zsh_highlight_use_redrawhook=1 )) fi From a8b842bddbdecc94811557c54e4d8c6f2d9be65b Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 16 Sep 2016 04:34:59 +0000 Subject: [PATCH 08/14] redo _zsh_highlight__function_callable_p --- zsh-syntax-highlighting.zsh | 51 ++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 5b56b08..40b3106 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -42,6 +42,25 @@ if true; then fi fi +# This function takes a single argument F and returns True iff F is an autoload stub. +_zsh_highlight__function_is_autoload_stub_p() { + if (( ${+functions} )); then + ## zsh/parameter is available + #(( ${+functions[$1]} )) && + [[ "$functions[$1]" == *"builtin autoload -X" ]] + else + ## zsh/parameter isn't available + #[[ $(type -wa -- "$1") == *'function'* ]] && + [[ "${${(@f)"$(which -- "$1")"}[2]}" == $'\t'$histchars[3]' undefined' ]] + fi + # Do nothing here: return the exit code of the if. +} + +# Return True iff the argument denotes a function name. +_zsh_highlight__is_function_p() { + (( ${+functions[$1]} )) || [[ $(type -wa -- "$1") == *'function'* ]] +} + # This function takes a single argument F and returns True iff F denotes the # name of a callable function. A function is callable if it is fully defined # or if it is marked for autoloading and autoloading it at the first call to it @@ -50,23 +69,21 @@ fi # # See users/21671 http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=21671 _zsh_highlight__function_callable_p() { - { # Trenary condition: if the zle/parameter module is available, ... - if (( ${+functions} )); then - # ... then use it to make the decision, ... - if (( ${+functions[$1]} )); then - [[ "$functions[$1]" != *"builtin autoload -X" ]] \ - || - ( unfunction -- "$1" && autoload -U +X -- "$1" 2>/dev/null ) - else - ( autoload -U +X -- "$1" 2>/dev/null ) - fi - else - # ... otherwise, use a fallback approach. - autoload -U +X -- "$1" 2>/dev/null - [[ "${${(@f)"$(which -- "$1")"}[2]}" != $'\t'$histchars[3]' undefined' ]] - fi - } - # Do nothing here! We return the exit code of the if. + if _zsh_highlight__is_function_p "$1" && + ! _zsh_highlight__function_is_autoload_stub_p "$1" + then + # Already fully loaded. + return 0 # true + else + # "$1" is either an autoload stub, or not a function at all. + # + # Use a subshell to avoid affecting the calling shell. + # + # We expect 'autoload +X' to return non-zero if it fails to fully load + # the function. + ( autoload -U +X -- "$1" 2>/dev/null ) + return $? + fi } integer zsh_highlight_use_redrawhook From 29c6834e709a701e0913d8667c0247091fe21a71 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 7 Oct 2016 14:21:57 +0000 Subject: [PATCH 09/14] docs: Update FAQ answer per changes on this branch. --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac8beaf..f455a1f 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,23 @@ FAQ ### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file? -`zsh-syntax-highlighting.zsh` wraps ZLE widgets. It must be sourced after all +zsh-syntax-highlighting works by hooking into the Zsh Line Editor (ZLE) and +computing syntax highlighting for the command-line buffer as it stands at the +time z-sy-h's hook is invoked. + +In zsh 5.2 and older, +`zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must be sourced after all custom widgets have been created (i.e., after all `zle -N` calls and after -running `compinit`). Widgets created later will work, but will not update the +running `compinit`) in order to be able to wrap all of them. +Widgets created after z-sy-h is sourced will work, but will not update the syntax highlighting. +In zsh 5.3 and newer, +zsh-syntax-highlighting uses the `add-zle-hook-widget` facility to install +a `zle-line-pre-redraw` hook. Hooks are run in order of registration, +therefore, z-sy-h must be sourced (and register its hook) after anything else +that adds hooks that modify the command-line buffer. + ### How are new releases announced? There is currently no "push" announcements channel. However, the following From 89bf5785909ac1ba04799e3939ed255f0340f033 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 7 Oct 2016 14:22:23 +0000 Subject: [PATCH 10/14] docs: Rewrap. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f455a1f..730e4f2 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ computing syntax highlighting for the command-line buffer as it stands at the time z-sy-h's hook is invoked. In zsh 5.2 and older, -`zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must be sourced after all -custom widgets have been created (i.e., after all `zle -N` calls and after -running `compinit`) in order to be able to wrap all of them. +`zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must +be sourced after all custom widgets have been created (i.e., after all `zle -N` +calls and after running `compinit`) in order to be able to wrap all of them. Widgets created after z-sy-h is sourced will work, but will not update the syntax highlighting. From 9872a186bcda46c050bb901425ad4fcbc5d53e92 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 17 Oct 2016 14:49:53 +0000 Subject: [PATCH 11/14] noop: Make a whitespace-only change to reduce noise in the next commit. --- zsh-syntax-highlighting.zsh | 86 +++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 40b3106..4300bed 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -274,50 +274,52 @@ _zsh_highlight_call_widget() _zsh_highlight } -# Rebind all ZLE widgets to make them invoke _zsh_highlights. -_zsh_highlight_bind_widgets() -{ - setopt localoptions noksharrays +if true; then + # Rebind all ZLE widgets to make them invoke _zsh_highlights. + _zsh_highlight_bind_widgets() + { + setopt localoptions noksharrays - # Load ZSH module zsh/zleparameter, needed to override user defined widgets. - zmodload zsh/zleparameter 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 - return 1 + # Load ZSH module zsh/zleparameter, needed to override user defined widgets. + zmodload zsh/zleparameter 2>/dev/null || { + echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 + return 1 + } + + # Override ZLE widgets to make them invoke _zsh_highlight. + local cur_widget + for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do + case $widgets[$cur_widget] in + + # Already rebound event: do nothing. + user:_zsh_highlight_widget_*);; + + # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function + # definition time is used. + # + # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with + # NO_function_argzero, regardless of the option's setting here. + + # User defined widget: override and rebind old one with prefix "orig-". + user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:} + eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; + + # Completion widget: override and rebind old one with prefix "orig-". + completion:*) zle -C orig-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} + eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; + + # Builtin widget: override and make it call the builtin ".widget". + builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; + + # Default: unhandled case. + *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; + esac + done } - - # Override ZLE widgets to make them invoke _zsh_highlight. - local cur_widget - for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do - case $widgets[$cur_widget] in - - # Already rebound event: do nothing. - user:_zsh_highlight_widget_*);; - - # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function - # definition time is used. - # - # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with - # NO_function_argzero, regardless of the option's setting here. - - # User defined widget: override and rebind old one with prefix "orig-". - user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:} - eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" - zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; - - # Completion widget: override and rebind old one with prefix "orig-". - completion:*) zle -C orig-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} - eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" - zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; - - # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" - zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; - - # Default: unhandled case. - *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; - esac - done -} +fi if (( $zsh_highlight_use_redrawhook )); then _zsh_highlight__zle-line-finish() { From 5591e2adb1f7c8d68c91bc18d8d3e6f01e9837eb Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 17 Oct 2016 15:12:24 +0000 Subject: [PATCH 12/14] driver: Rewrite without a state variable Suggested-by: m0viefreak --- zsh-syntax-highlighting.zsh | 41 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 4300bed..e6070c0 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -86,13 +86,6 @@ _zsh_highlight__function_callable_p() { fi } -integer zsh_highlight_use_redrawhook -if _zsh_highlight__function_callable_p add-zle-hook-widget -then - autoload -U add-zle-hook-widget - (( zsh_highlight_use_redrawhook=1 )) -fi - # ------------------------------------------------------------------------------------------------- # Core highlighting update system # ------------------------------------------------------------------------------------------------- @@ -274,7 +267,23 @@ _zsh_highlight_call_widget() _zsh_highlight } -if true; then +if _zsh_highlight__function_callable_p add-zle-hook-widget +then + autoload -U add-zle-hook-widget + _zsh_highlight__zle-line-finish() { + # Reset $WIDGET since the 'main' highlighter depends on it. + # + # A nested function is required to hide zle parameters; see + # "User-defined widgets" in zshall. + () { + local -h +r WIDGET=zle-line-finish + _zsh_highlight "$@" + } "$@" + } + _zsh_highlight_bind_widgets(){} + add-zle-hook-widget zle-line-pre-redraw _zsh_highlight + add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish +else # Rebind all ZLE widgets to make them invoke _zsh_highlights. _zsh_highlight_bind_widgets() { @@ -321,22 +330,6 @@ if true; then } fi -if (( $zsh_highlight_use_redrawhook )); then - _zsh_highlight__zle-line-finish() { - # Reset $WIDGET since the 'main' highlighter depends on it. - # - # A nested function is required to hide zle parameters; see - # "User-defined widgets" in zshall. - () { - local -h +r WIDGET=zle-line-finish - _zsh_highlight "$@" - } "$@" - } - _zsh_highlight_bind_widgets(){} - add-zle-hook-widget zle-line-pre-redraw _zsh_highlight - add-zle-hook-widget zle-line-finish _zsh_highlight__zle-line-finish -fi - # Load highlighters from directory. # # Arguments: From efa432241d62d6755dfd3fb3a5e7a89e4b2bcce0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 17 Oct 2016 17:51:04 +0000 Subject: [PATCH 13/14] test harness: Actually test the new code. Currently, without zsh/zle loaded, the tests silently fall back to the 5.2-and-earlier codepath; see: . https://github.com/zsh-users/zsh-syntax-highlighting/pull/356#issuecomment-243651251 --- tests/generate.zsh | 3 +++ tests/test-highlighting.zsh | 3 +++ tests/test-perfs.zsh | 3 +++ 3 files changed, 9 insertions(+) diff --git a/tests/generate.zsh b/tests/generate.zsh index 64a1ede..ef89f94 100755 --- a/tests/generate.zsh +++ b/tests/generate.zsh @@ -31,6 +31,9 @@ emulate -LR zsh setopt localoptions extendedglob +# Required for add-zle-hook-widget. +zmodload zsh/zle + # Argument parsing. if (( $# != 3 )) || [[ $1 == -* ]]; then print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME" diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index 1d169d6..243f846 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -29,6 +29,9 @@ # ------------------------------------------------------------------------------------------------- +# Required for add-zle-hook-widget. +zmodload zsh/zle + # Check an highlighter was given as argument. [[ -n "$1" ]] || { echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." diff --git a/tests/test-perfs.zsh b/tests/test-perfs.zsh index 3411754..49d95c7 100755 --- a/tests/test-perfs.zsh +++ b/tests/test-perfs.zsh @@ -29,6 +29,9 @@ # ------------------------------------------------------------------------------------------------- +# Required for add-zle-hook-widget. +zmodload zsh/zle + # Check an highlighter was given as argument. [[ -n "$1" ]] || { echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." From 7d38d07255e4fc6330456047823eb180ec60fff6 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 17 Oct 2016 20:46:46 +0000 Subject: [PATCH 14/14] 'main': Followup to fdaeec45146b: Update comment. That revision was itself a followup to 51614ca2c994. --- highlighters/main/main-highlighter.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index f7aa2a9..1bbc3cb 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -140,7 +140,7 @@ _zsh_highlight_main__type() { # exists and is in $PATH). Avoid triggering the bug, at the expense of # falling through to the $() below, incurring a fork. (Issue #354.) # - # The second disjunct mimics the isrelative() C call from the zsh bug. + # The first disjunct mimics the isrelative() C call from the zsh bug. elif { [[ $1 != */* ]] || is-at-least 5.3 } && ! builtin type -w -- $1 >/dev/null 2>&1; then REPLY=none