File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 3434# Whether the cursor highlighter should be called or not.
3535_zsh_highlight_cursor_highlighter_predicate ()
3636{
37- # accept-* may trigger removal of cursor highlighting
38- [[ $WIDGET == accept-* ]] ||
39- _zsh_highlight_cursor_moved
37+ # remove cursor highlighting when the line is finished
38+ [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved
4039}
4140
4241# Cursor highlighting function.
4342_zsh_highlight_cursor_highlighter ()
4443{
45- [[ $WIDGET == accept- * ]] && return
44+ [[ $WIDGET == zle-line-finish ]] && return
4645
4746 region_highlight+=(" $CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES [cursor]" )
4847}
Original file line number Diff line number Diff line change 6060# Whether the highlighter should be called or not.
6161_zsh_highlight_main_highlighter_predicate ()
6262{
63- # accept-* may trigger removal of path_prefix highlighting
64- [[ $WIDGET == accept-* ]] ||
65- _zsh_highlight_buffer_modified
63+ # may need to remove path_prefix highlighting when the line ends
64+ [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified
6665}
6766
6867# Helper to deal with tokens crossing line boundaries.
@@ -486,7 +485,7 @@ _zsh_highlight_main_highlighter_check_path()
486485
487486 # If this word ends the buffer, check if it's the prefix of a valid path.
488487 if [[ ${BUFFER[1]} != " -" && ${# BUFFER} == $end_pos ]] &&
489- [[ $WIDGET != accept- * ]]; then
488+ [[ $WIDGET != zle-line-finish ]]; then
490489 local -a tmp
491490 tmp=( ${expanded_path} * (N) )
492491 (( $# tmp > 0 )) && style_override=path_prefix && return 0
Original file line number Diff line number Diff line change 3232
3333ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight
3434BUFFER=' ls /bin/s'
35- WIDGET=accept -line
35+ WIDGET=zle -line-finish
3636
3737expected_region_highlight=(
3838 " 4 9 $ZSH_HIGHLIGHT_STYLES [default]" # /bin/s
Original file line number Diff line number Diff line change @@ -308,6 +308,11 @@ _zsh_highlight_bind_widgets || {
308308 return 1
309309}
310310
311+ # Always wrap special zle-line-finish widget. This is needed to decide if the
312+ # current line ends and special highlighting logic needs to be applied.
313+ # E.g. remove cursor imprint, don't highlight partial paths, ...
314+ _zsh_highlight_set_or_wrap_special_zle_widget zle-line-finish
315+
311316# Resolve highlighters directory location.
312317_zsh_highlight_load_highlighters " ${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:- ${${0: A} : h} / highlighters} " || {
313318 echo ' zsh-syntax-highlighting: failed loading highlighters, exiting.' >&2
You can’t perform that action at this time.
0 commit comments