Skip to content

Commit a5b8bc0

Browse files
committed
'main': Internal cleanup: drop $style_override.
Changes the interface of _zsh_highlight_main_highlighter_check_path(). Suggested-by: m0viefreak
1 parent 3b67e65 commit a5b8bc0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

highlighters/main/main-highlighter.zsh

+7-6
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ _zsh_highlight_main_highlighter()
271271
# which add the entry early so escape sequences within the string override
272272
# the string's color.
273273
integer already_added=0
274-
local style_override=""
275274
if [[ $this_word == *':start:'* ]]; then
276275
in_array_assignment=false
277276
if [[ $arg == 'noglob' ]]; then
@@ -456,7 +455,7 @@ _zsh_highlight_main_highlighter()
456455
style=reserved-word
457456
else
458457
if _zsh_highlight_main_highlighter_check_path; then
459-
style=path
458+
style=$REPLY
460459
else
461460
style=unknown-token
462461
fi
@@ -507,16 +506,14 @@ _zsh_highlight_main_highlighter()
507506
(( in_redirection=2 ))
508507
else
509508
if _zsh_highlight_main_highlighter_check_path; then
510-
style=path
509+
style=$REPLY
511510
else
512511
style=default
513512
fi
514513
fi
515514
;;
516515
esac
517516
fi
518-
# if a style_override was set (eg in _zsh_highlight_main_highlighter_check_path), use it
519-
[[ -n $style_override ]] && style=$style_override
520517
(( already_added )) || _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
521518
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
522519
next_word=':start:'
@@ -547,11 +544,15 @@ _zsh_highlight_main_highlighter_check_assign()
547544
}
548545

549546
# Check if $arg is a path.
547+
# If yes, return 0 and in $REPLY the style to use.
548+
# Else, return non-zero (and the contents of $REPLY is undefined).
550549
_zsh_highlight_main_highlighter_check_path()
551550
{
552551
_zsh_highlight_main_highlighter_expand_path $arg;
553552
local expanded_path="$REPLY"
554553

554+
REPLY=path
555+
555556
[[ -z $expanded_path ]] && return 1
556557
[[ -e $expanded_path ]] && return 0
557558

@@ -569,7 +570,7 @@ _zsh_highlight_main_highlighter_check_path()
569570
[[ $WIDGET != accept-* ]]; then
570571
local -a tmp
571572
tmp=( ${expanded_path}*(N) )
572-
(( $#tmp > 0 )) && style_override=path_prefix && return 0
573+
(( $#tmp > 0 )) && REPLY=path_prefix && return 0
573574
fi
574575

575576
# It's not a path.

0 commit comments

Comments
 (0)