Merge pull request #140 from randomize/pr_fix_issue_#77
Pr fix issue #77
This commit is contained in:
		
						commit
						3dc5741900
					
				|  | @ -49,6 +49,7 @@ _zsh_highlight_brackets_highlighter() | ||||||
| { | { | ||||||
|   local level=0 pos |   local level=0 pos | ||||||
|   local -A levelpos lastoflevel matching typepos |   local -A levelpos lastoflevel matching typepos | ||||||
|  |   region_highlight=() | ||||||
| 
 | 
 | ||||||
|   # Find all brackets and remember which one is matching |   # Find all brackets and remember which one is matching | ||||||
|   for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do |   for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do | ||||||
|  |  | ||||||
|  | @ -54,37 +54,42 @@ _zsh_highlight() | ||||||
|   # Do not highlight if there are pending inputs (copy/paste). |   # Do not highlight if there are pending inputs (copy/paste). | ||||||
|   [[ $PENDING -gt 0 ]] && return $ret |   [[ $PENDING -gt 0 ]] && return $ret | ||||||
| 
 | 
 | ||||||
|  |   # Reset region highlight to build it from scratch | ||||||
|  |   region_highlight=(); | ||||||
|  | 
 | ||||||
|   { |   { | ||||||
|     local -a selected_highlighters |  | ||||||
|     local cache_place |     local cache_place | ||||||
|  |     local -a region_highlight_copy | ||||||
| 
 | 
 | ||||||
|     # Select which highlighters in ZSH_HIGHLIGHT_HIGHLIGHTERS need to be invoked. |     # Select which highlighters in ZSH_HIGHLIGHT_HIGHLIGHTERS need to be invoked. | ||||||
|     local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do |     local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do | ||||||
| 
 | 
 | ||||||
|  |       # eval cache place for current highlighter and prepare it | ||||||
|  |       cache_place="_zsh_highlight_${highlighter}_highlighter_cache" | ||||||
|  |       typeset -ga ${cache_place} | ||||||
|  | 
 | ||||||
|       # If highlighter needs to be invoked |       # If highlighter needs to be invoked | ||||||
|       if "_zsh_highlight_${highlighter}_highlighter_predicate"; then |       if "_zsh_highlight_${highlighter}_highlighter_predicate"; then | ||||||
| 
 | 
 | ||||||
|         # Mark the highlighter as selected for update. |         # save a copy, and cleanup region_highlight | ||||||
|         selected_highlighters+=($highlighter) |         region_highlight_copy=("${region_highlight[@]}") | ||||||
|  |         region_highlight=() | ||||||
| 
 | 
 | ||||||
|         # Remove what was stored in its cache from region_highlight. |         # Execute highlighter and save result | ||||||
|         cache_place="_zsh_highlight_${highlighter}_highlighter_cache" |         { | ||||||
|         typeset -ga ${cache_place} |           "_zsh_highlight_${highlighter}_highlighter" | ||||||
|         [[ ${#${(P)cache_place}} -gt 0 ]] && [[ ! -z ${region_highlight-} ]] && region_highlight=(${region_highlight:#(${(P~j.|.)cache_place})}) |         } always { | ||||||
|  |           eval "${cache_place}=(\"\${region_highlight[@]}\")" | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         # Restore saved region_highlight | ||||||
|  |         region_highlight=("${region_highlight_copy[@]}") | ||||||
| 
 | 
 | ||||||
|       fi |       fi | ||||||
|     done |  | ||||||
| 
 | 
 | ||||||
|     # Invoke each selected highlighter and store the result in its cache. |       # Use value form cache if any cached | ||||||
|     local -a region_highlight_copy |       eval "region_highlight+=(\"\${${cache_place}[@]}\")" | ||||||
|     for highlighter in $selected_highlighters; do | 
 | ||||||
|       cache_place="_zsh_highlight_${highlighter}_highlighter_cache" |  | ||||||
|       region_highlight_copy=($region_highlight) |  | ||||||
|       { |  | ||||||
|         "_zsh_highlight_${highlighter}_highlighter" |  | ||||||
|       } always  { |  | ||||||
|         [[ ! -z ${region_highlight-} ]] && : ${(PA)cache_place::=${region_highlight:#(${(~j.|.)region_highlight_copy})}} |  | ||||||
|       } |  | ||||||
|     done |     done | ||||||
| 
 | 
 | ||||||
|   } always { |   } always { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue