Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions highlighters/cursor/cursor-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# widgets which accept lines may trigger removal of cursor highlighting
_zsh_highlight_cursor_moved || _zsh_highlight_is_accept_line_type_widget
}

# Cursor highlighting function.
_zsh_highlight_cursor_highlighter()
{
[[ $WIDGET == accept-* ]] && return
_zsh_highlight_is_accept_line_type_widget && return

region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]")
}
6 changes: 3 additions & 3 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
# Whether the highlighter should be called or not.
_zsh_highlight_main_highlighter_predicate()
{
# accept-* may trigger removal of path_prefix highlighting
[[ $WIDGET == accept-* ]] ||
# widgets which accept lines may trigger removal of path_prefix highlighting
_zsh_highlight_is_accept_line_type_widget ||
_zsh_highlight_buffer_modified
}

Expand Down Expand Up @@ -455,7 +455,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
! _zsh_highlight_is_accept_line_type_widget; then
local -a tmp
tmp=( ${expanded_path}*(N) )
(( $#tmp > 0 )) && style_override=path_prefix && return 0
Expand Down
8 changes: 8 additions & 0 deletions zsh-syntax-highlighting.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ _zsh_highlight_cursor_moved()
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
}

# Whether the current widget is an accept-line type widget.
#
# Returns 0 if the the current widget is an accept-line type widget.
_zsh_highlight_is_accept_line_type_widget()
{
[[ $WIDGET == accept-* ]] || [[ $WIDGET == zsh-isearch-exit ]]
}


# -------------------------------------------------------------------------------------------------
# Setup functions
Expand Down