Fix issue #228, "Support the PATH_DIRS option".
This commit is contained in:
parent
a636527f70
commit
96ee5116b1
@ -83,19 +83,33 @@ _zsh_highlight_main_add_region_highlight() {
|
||||
# Main syntax highlighting function.
|
||||
_zsh_highlight_main_highlighter()
|
||||
{
|
||||
## Before we even 'emulate -L', we must test a few options that would reset.
|
||||
if [[ -o interactive_comments ]]; then
|
||||
local interactive_comments= # set to empty
|
||||
fi
|
||||
if [[ -o path_dirs ]]; then
|
||||
integer path_dirs_was_set=1
|
||||
else
|
||||
integer path_dirs_was_set=0
|
||||
fi
|
||||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual
|
||||
|
||||
## Variable declarations and initializations
|
||||
local start_pos=0 end_pos highlight_glob=true arg style
|
||||
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
|
||||
local -a options_to_set
|
||||
local buf="$PREBUFFER$BUFFER"
|
||||
region_highlight=()
|
||||
|
||||
if (( path_dirs_was_set )); then
|
||||
options_to_set+=( PATH_DIRS )
|
||||
fi
|
||||
unset path_dirs_was_set
|
||||
|
||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||
'|' '||' ';' '&' '&&'
|
||||
)
|
||||
@ -239,7 +253,12 @@ _zsh_highlight_main_highlighter()
|
||||
else
|
||||
_zsh_highlight_main_highlighter_expand_path $arg
|
||||
local expanded_arg="$REPLY"
|
||||
local res="$(LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null)"
|
||||
local res="$(
|
||||
if (( $#options_to_set )); then
|
||||
setopt $options_to_set;
|
||||
fi
|
||||
LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null
|
||||
)"
|
||||
case $res in
|
||||
*': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];;
|
||||
*': suffix alias')
|
||||
|
@ -37,5 +37,5 @@ path+=( "$PWD"/foo )
|
||||
BUFFER='bar/testing-issue-228'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 21 $ZSH_HIGHLIGHT_STYLES[command] 'issue #228'" # bar/testing-issue-228
|
||||
"1 21 $ZSH_HIGHLIGHT_STYLES[command]" # bar/testing-issue-228
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user