|
62 | 62 | typeset -g zsh_highlight__pat_static_bug=true |
63 | 63 | fi |
64 | 64 |
|
65 | | -# Array declaring active highlighters names. |
66 | | -typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS |
| 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 |
67 | 70 |
|
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. |
87 | 71 | (( ${+zsh_highlight__memo_feature} )) || { |
88 | 72 | region_highlight+=( " 0 0 fg=red, memo=zsh-syntax-highlighting" ) |
89 | 73 | case ${region_highlight[-1]} in |
@@ -126,6 +110,28 @@ _zsh_highlight() |
126 | 110 | esac |
127 | 111 | region_highlight[-1]=() |
128 | 112 | } |
| 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 | + } |
129 | 135 |
|
130 | 136 | # Reset region_highlight to build it from scratch |
131 | 137 | if (( zsh_highlight__memo_feature )); then |
|
0 commit comments