mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-01-30 09:47:13 +08:00
Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
This reverts commit 8a1bd7c8b6
.
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.
This commit is contained in:
parent
8a1bd7c8b6
commit
d62baa50f4
@ -62,12 +62,28 @@ else
|
||||
typeset -g zsh_highlight__pat_static_bug=true
|
||||
fi
|
||||
|
||||
# Probe the memo= feature, once. When this anonymous function returns,
|
||||
# $zsh_highlight__memo_feature will be set (either to 0 or to 1).
|
||||
() {
|
||||
# Provide a mock $region_highlight. (The test suite's mock might not have been set up yet.)
|
||||
(( ${+region_highlight} )) || typeset -a region_highlight
|
||||
# Array declaring active highlighters names.
|
||||
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
|
||||
|
||||
# Update ZLE buffer syntax highlighting.
|
||||
#
|
||||
# Invokes each highlighter that needs updating.
|
||||
# This function is supposed to be called whenever the ZLE state changes.
|
||||
_zsh_highlight()
|
||||
{
|
||||
# Store the previous command return code to restore it whatever happens.
|
||||
local ret=$?
|
||||
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.
|
||||
typeset -r ret
|
||||
|
||||
# $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.
|
||||
(( ${+region_highlight} )) || {
|
||||
echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined'
|
||||
echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)'
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Probe the memo= feature, once.
|
||||
(( ${+zsh_highlight__memo_feature} )) || {
|
||||
region_highlight+=( " 0 0 fg=red, memo=zsh-syntax-highlighting" )
|
||||
case ${region_highlight[-1]} in
|
||||
@ -110,28 +126,6 @@ fi
|
||||
esac
|
||||
region_highlight[-1]=()
|
||||
}
|
||||
}
|
||||
|
||||
# Array declaring active highlighters names.
|
||||
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
|
||||
|
||||
# Update ZLE buffer syntax highlighting.
|
||||
#
|
||||
# Invokes each highlighter that needs updating.
|
||||
# This function is supposed to be called whenever the ZLE state changes.
|
||||
_zsh_highlight()
|
||||
{
|
||||
# Store the previous command return code to restore it whatever happens.
|
||||
local ret=$?
|
||||
# Make it read-only. Can't combine this with the previous line when POSIX_BUILTINS may be set.
|
||||
typeset -r ret
|
||||
|
||||
# $region_highlight should be predefined, either by zle or by the test suite's mock (non-special) array.
|
||||
(( ${+region_highlight} )) || {
|
||||
echo >&2 'zsh-syntax-highlighting: error: $region_highlight is not defined'
|
||||
echo >&2 'zsh-syntax-highlighting: (Check whether zsh-syntax-highlighting was installed according to the instructions.)'
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Reset region_highlight to build it from scratch
|
||||
if (( zsh_highlight__memo_feature )); then
|
||||
|
Loading…
Reference in New Issue
Block a user