mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-13 10:05:31 +08:00
reverse my inital changes to put on branch instead
This commit is contained in:
parent
b46769b181
commit
a5a28a194a
@ -95,7 +95,7 @@ _zsh_highlight_main_add_region_highlight() {
|
||||
|
||||
# The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
|
||||
# relative to $BUFFER.
|
||||
(( start -= $#PREBUFFER )) || :
|
||||
(( start -= $#PREBUFFER ))
|
||||
(( end -= $#PREBUFFER ))
|
||||
|
||||
(( end < 0 )) && return # having end<0 would be a bug
|
||||
@ -146,8 +146,8 @@ _zsh_highlight_main__type() {
|
||||
REPLY=none
|
||||
fi
|
||||
fi
|
||||
if ! (( $+REPLY )); then # below will frequently trigger ERR trap without || :
|
||||
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null || :)#*: }"
|
||||
if ! (( $+REPLY )); then
|
||||
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }"
|
||||
fi
|
||||
if (( $+_zsh_highlight_main__command_type_cache )); then
|
||||
_zsh_highlight_main__command_type_cache[(e)$1]=$REPLY
|
||||
@ -214,7 +214,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
integer multi_func_def=0
|
||||
fi
|
||||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual #xtrace
|
||||
setopt localoptions extendedglob bareglobqual
|
||||
|
||||
# At the PS3 prompt and in vared, highlight nothing.
|
||||
#
|
||||
@ -384,7 +384,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
else
|
||||
integer offset=0
|
||||
fi
|
||||
((start_pos+=offset)) || :
|
||||
((start_pos+=offset))
|
||||
((end_pos=$start_pos+${#arg}))
|
||||
fi
|
||||
|
||||
@ -537,9 +537,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
style=alias
|
||||
_zsh_highlight_main__resolve_alias $arg
|
||||
local alias_target="$REPLY"
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"}
|
||||
&& -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] &&
|
||||
ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) || :
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
|
||||
fi
|
||||
}
|
||||
;;
|
||||
@ -686,7 +684,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
fi
|
||||
if ! (( already_added )); then
|
||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||
[[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators || :
|
||||
[[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators
|
||||
fi
|
||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
||||
if [[ $arg == ';' ]] && $in_array_assignment; then
|
||||
|
@ -109,11 +109,8 @@ _zsh_highlight()
|
||||
return $ret
|
||||
fi
|
||||
|
||||
# Did a couple of tweaks to highlighters/main/main-highlighter.zsh
|
||||
# to prevent need for following, though there'll surely be other areas.
|
||||
# setopt localtraps
|
||||
# unfunction TRAPZERR
|
||||
setopt localoptions noksharrays warncreateglobal
|
||||
setopt localoptions warncreateglobal
|
||||
setopt localoptions noksharrays
|
||||
local REPLY # don't leak $REPLY into global scope
|
||||
|
||||
# Do not highlight if there are more than 300 chars in the buffer. It's most
|
||||
@ -216,8 +213,7 @@ _zsh_highlight_apply_zle_highlight() {
|
||||
local entry="$1" default="$2"
|
||||
integer first="$3" second="$4"
|
||||
|
||||
setopt localoptions unset # seems to be the accessing the array entry
|
||||
# rather than ${entry-} that aborts otherwise
|
||||
setopt localoptions unset # Is it bug or feature that nounset will often abort this function?
|
||||
|
||||
# read the relevant entry from zle_highlight
|
||||
local region="${zle_highlight[(r)${entry}:*]}"
|
||||
@ -402,7 +398,7 @@ _zsh_highlight_load_highlighters()
|
||||
for highlighter_dir ($1/*/); do
|
||||
highlighter="${highlighter_dir:t}"
|
||||
[[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] &&
|
||||
source "$highlighter_dir/${highlighter}-highlighter.zsh"
|
||||
. "$highlighter_dir/${highlighter}-highlighter.zsh"
|
||||
if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null &&
|
||||
type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null;
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user