'driver': Always bind zle-line-finish and use it instead of accept-*
Special handling for cursor imprint or partial path highlighting is needed in more cases than accept-*. For example when accepting a line from isearch, no accept-* widget is invoked. The proper way is to use zle-line-finish. Trumps #259. Fixes #284.
This commit is contained in:
		
							parent
							
								
									f9c95b2ef3
								
							
						
					
					
						commit
						8dfe7b0910
					
				| 
						 | 
				
			
			@ -34,15 +34,14 @@
 | 
			
		|||
# Whether the cursor highlighter should be called or not.
 | 
			
		||||
_zsh_highlight_cursor_highlighter_predicate()
 | 
			
		||||
{
 | 
			
		||||
  # accept-* may trigger removal of cursor highlighting
 | 
			
		||||
  [[ $WIDGET == accept-* ]] ||
 | 
			
		||||
    _zsh_highlight_cursor_moved
 | 
			
		||||
  # remove cursor highlighting when the line is finished
 | 
			
		||||
  [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Cursor highlighting function.
 | 
			
		||||
_zsh_highlight_cursor_highlighter()
 | 
			
		||||
{
 | 
			
		||||
  [[ $WIDGET == accept-* ]] && return
 | 
			
		||||
  [[ $WIDGET == zle-line-finish ]] && return
 | 
			
		||||
  
 | 
			
		||||
  _zsh_highlight_add_highlight $CURSOR $(( $CURSOR + 1 )) cursor
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,9 +62,8 @@
 | 
			
		|||
# Whether the highlighter should be called or not.
 | 
			
		||||
_zsh_highlight_main_highlighter_predicate()
 | 
			
		||||
{
 | 
			
		||||
  # accept-* may trigger removal of path_prefix highlighting
 | 
			
		||||
  [[ $WIDGET == accept-* ]] ||
 | 
			
		||||
    _zsh_highlight_buffer_modified
 | 
			
		||||
  # may need to remove path_prefix highlighting when the line ends
 | 
			
		||||
  [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Helper to deal with tokens crossing line boundaries.
 | 
			
		||||
| 
						 | 
				
			
			@ -595,7 +594,7 @@ _zsh_highlight_main_highlighter_check_path()
 | 
			
		|||
 | 
			
		||||
  # If this word ends the buffer, check if it's the prefix of a valid path.
 | 
			
		||||
  if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]] &&
 | 
			
		||||
     [[ $WIDGET != accept-* ]]; then
 | 
			
		||||
     [[ $WIDGET != zle-line-finish ]]; then
 | 
			
		||||
    local -a tmp
 | 
			
		||||
    tmp=( ${expanded_path}*(N) )
 | 
			
		||||
    (( $#tmp > 0 )) && REPLY=path_prefix && return 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@
 | 
			
		|||
# Related to path_prefix.zsh
 | 
			
		||||
 | 
			
		||||
BUFFER='ls /bin/s'
 | 
			
		||||
WIDGET=accept-line
 | 
			
		||||
WIDGET=zle-line-finish
 | 
			
		||||
 | 
			
		||||
expected_region_highlight=(
 | 
			
		||||
  "4 9 default"    # /bin/s
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,6 +237,12 @@ _zsh_highlight_bind_widgets()
 | 
			
		|||
  # Override ZLE widgets to make them invoke _zsh_highlight.
 | 
			
		||||
  local -U widgets_to_bind
 | 
			
		||||
  widgets_to_bind=(${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)})
 | 
			
		||||
 | 
			
		||||
  # Always wrap special zle-line-finish widget. This is needed to decide if the
 | 
			
		||||
  # current line ends and special highlighting logic needs to be applied.
 | 
			
		||||
  # E.g. remove cursor imprint, don't highlight partial paths, ...
 | 
			
		||||
  widgets_to_bind+=(zle-line-finish)
 | 
			
		||||
 | 
			
		||||
  local cur_widget
 | 
			
		||||
  for cur_widget in $widgets_to_bind; do
 | 
			
		||||
    case $widgets[$cur_widget] in
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue