Skip to content

Commit d62baa5

Browse files
committed
Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
This reverts commit 8a1bd7c. The detection only works correctly from a widget function, so the change was wrong: it caused zsh_highlight__memo_feature to be set to false every time.
1 parent 8a1bd7c commit d62baa5

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

zsh-syntax-highlighting.zsh

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,28 @@ else
6262
typeset -g zsh_highlight__pat_static_bug=true
6363
fi
6464

65-
# Probe the memo= feature, once. When this anonymous function returns,
66-
# $zsh_highlight__memo_feature will be set (either to 0 or to 1).
67-
() {
68-
# Provide a mock $region_highlight. (The test suite's mock might not have been set up yet.)
69-
(( ${+region_highlight} )) || typeset -a region_highlight
65+
# Array declaring active highlighters names.
66+
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
7067

68+
# Update ZLE buffer syntax highlighting.
69+
#
70+
# Invokes each highlighter that needs updating.
71+
# This function is supposed to be called whenever the ZLE state changes.
72+
_zsh_highlight()
73+
{
74+
# Store the previous command return code to restore it whatever happens.
75+
local ret=$?
76+
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.
77+
typeset -r ret
78+
79+
# $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.
80+
(( ${+region_highlight} )) || {
81+
echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined'
82+
echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)'
83+
return $ret
84+
}
85+
86+
# Probe the memo= feature, once.
7187
(( ${+zsh_highlight__memo_feature} )) || {
7288
region_highlight+=( " 0 0 fg=red, memo=zsh-syntax-highlighting" )
7389
case ${region_highlight[-1]} in
@@ -110,28 +126,6 @@ fi
110126
esac
111127
region_highlight[-1]=()
112128
}
113-
}
114-
115-
# Array declaring active highlighters names.
116-
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
117-
118-
# Update ZLE buffer syntax highlighting.
119-
#
120-
# Invokes each highlighter that needs updating.
121-
# This function is supposed to be called whenever the ZLE state changes.
122-
_zsh_highlight()
123-
{
124-
# Store the previous command return code to restore it whatever happens.
125-
local ret=$?
126-
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.
127-
typeset -r ret
128-
129-
# $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.
130-
(( ${+region_highlight} )) || {
131-
echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined'
132-
echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)'
133-
return $ret
134-
}
135129

136130
# Reset region_highlight to build it from scratch
137131
if (( zsh_highlight__memo_feature )); then

0 commit comments

Comments
 (0)