Skip to content

Commit ff8c413

Browse files
committed
Perf: speed up _zsh_highlight_main_add_region_highlight
1 parent 256913c commit ff8c413

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,20 @@ _zsh_highlight_highlighter_main_predicate()
7373

7474
# Helper to deal with tokens crossing line boundaries.
7575
_zsh_highlight_main_add_region_highlight() {
76-
integer start=$1 end=$2
77-
shift 2
78-
7976
if (( in_alias )); then
80-
[[ $1 == unknown-token ]] && alias_style=unknown-token
77+
[[ $3 == unknown-token ]] && alias_style=unknown-token
8178
return
8279
fi
80+
8381
if (( in_param )); then
84-
if [[ $1 == unknown-token ]]; then
85-
param_style=unknown-token
82+
if [[ -z $param_style || $3 == unknown-token ]]; then
83+
param_style=$3
8684
fi
87-
if [[ -n $param_style ]]; then
88-
return
89-
fi
90-
param_style=$1
9185
return
9286
fi
9387

9488
# The calculation was relative to $buf but region_highlight is relative to $BUFFER.
95-
(( start += buf_offset ))
96-
(( end += buf_offset ))
97-
98-
list_highlights+=($start $end $1)
89+
list_highlights+=($(( $1 + buf_offset )) $(( $2 + buf_offset )) $3)
9990
}
10091

10192
_zsh_highlight_main_add_many_region_highlights() {

0 commit comments

Comments
 (0)