Skip to content

Commit 4f0796b

Browse files
committed
treat zle-isearch-exit like an accept-* widget
Accepting a line in an iserch does not call through any of the accept-widgets. To be able to still do some cleanup (remove cursor imprint, remove partial path highlinting) use zle-isearch-exit instead.
1 parent 38c3ac8 commit 4f0796b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

highlighters/cursor/cursor-highlighter.zsh

+4-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@
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+
# widgets which accept lines may trigger removal of cursor highlighting
38+
_zsh_highlight_cursor_moved || _zsh_highlight_is_accept_line_type_widget
4039
}
4140

4241
# Cursor highlighting function.
4342
_zsh_highlight_cursor_highlighter()
4443
{
45-
[[ $WIDGET == accept-* ]] && return
46-
44+
_zsh_highlight_is_accept_line_type_widget && return
45+
4746
region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]")
4847
}

highlighters/main/main-highlighter.zsh

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
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-* ]] ||
63+
# widgets which accept lines may trigger removal of path_prefix highlighting
64+
_zsh_highlight_is_accept_line_type_widget ||
6565
_zsh_highlight_buffer_modified
6666
}
6767

@@ -455,7 +455,7 @@ _zsh_highlight_main_highlighter_check_path()
455455

456456
# If this word ends the buffer, check if it's the prefix of a valid path.
457457
if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]] &&
458-
[[ $WIDGET != accept-* ]]; then
458+
! _zsh_highlight_is_accept_line_type_widget; then
459459
local -a tmp
460460
tmp=( ${expanded_path}*(N) )
461461
(( $#tmp > 0 )) && style_override=path_prefix && return 0

zsh-syntax-highlighting.zsh

+8
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ _zsh_highlight_cursor_moved()
174174
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
175175
}
176176

177+
# Whether the current widget is an accept-line type widget.
178+
#
179+
# Returns 0 if the the current widget is an accept-line type widget.
180+
_zsh_highlight_is_accept_line_type_widget()
181+
{
182+
[[ $1 == accept-* ]] || [[ $1 == zsh-isearch-exit ]]
183+
}
184+
177185

178186
# -------------------------------------------------------------------------------------------------
179187
# Setup functions

0 commit comments

Comments
 (0)