File tree 3 files changed +21
-8
lines changed
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 34
34
# Whether the cursor highlighter should be called or not.
35
35
_zsh_highlight_cursor_highlighter_predicate ()
36
36
{
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
40
39
}
41
40
42
41
# Cursor highlighting function.
43
42
_zsh_highlight_cursor_highlighter ()
44
43
{
45
- [[ $WIDGET == accept- * ]] && return
46
-
44
+ _zsh_highlight_is_accept_line_type_widget && return
45
+
47
46
region_highlight+=(" $CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES [cursor]" )
48
47
}
Original file line number Diff line number Diff line change 60
60
# Whether the highlighter should be called or not.
61
61
_zsh_highlight_main_highlighter_predicate ()
62
62
{
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 ||
65
65
_zsh_highlight_buffer_modified
66
66
}
67
67
@@ -455,7 +455,7 @@ _zsh_highlight_main_highlighter_check_path()
455
455
456
456
# If this word ends the buffer, check if it's the prefix of a valid path.
457
457
if [[ ${BUFFER[1]} != " -" && ${# BUFFER} == $end_pos ]] &&
458
- [[ $WIDGET != accept- * ]] ; then
458
+ ! _zsh_highlight_is_accept_line_type_widget ; then
459
459
local -a tmp
460
460
tmp=( ${expanded_path} * (N) )
461
461
(( $# tmp > 0 )) && style_override=path_prefix && return 0
Original file line number Diff line number Diff line change 53
53
# Array declaring active highlighters names.
54
54
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
55
55
56
+ # Array declaring accept-style widget names.
57
+ typeset -ga ZSH_HIGHLIGHT_ACCEPTING_WIDGETS
58
+
56
59
# Update ZLE buffer syntax highlighting.
57
60
#
58
61
# Invokes each highlighter that needs updating.
@@ -174,6 +177,14 @@ _zsh_highlight_cursor_moved()
174
177
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (( $_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR ))
175
178
}
176
179
180
+ # Whether the current widget is an accept-line type widget.
181
+ #
182
+ # Returns 0 if the the current widget is an accept-line type widget.
183
+ _zsh_highlight_is_accept_line_type_widget ()
184
+ {
185
+ [[ $WIDGET == ${~" ${:- (${(j: |: )ZSH_HIGHLIGHT_ACCEPTING_WIDGETS} )} " } ]]
186
+ }
187
+
177
188
178
189
# -------------------------------------------------------------------------------------------------
179
190
# Setup functions
@@ -284,3 +295,6 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
284
295
285
296
# Initialize the array of active highlighters if needed.
286
297
[[ $# ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true
298
+
299
+ # Initialize the array of accept-style widgets if needed.
300
+ [[ $# ZSH_HIGHLIGHT_ACCEPTING_WIDGETS -eq 0 ]] && ZSH_HIGHLIGHT_ACCEPTING_WIDGETS=(' accept-*' zle-isearch-exit) || true
You can’t perform that action at this time.
0 commit comments