mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-21 19:03:11 +00:00
*highlight: Correctly highlight complex [[ conditions
This commit is contained in:
parent
6763e91914
commit
517ae74172
1 changed files with 12 additions and 0 deletions
|
@ -415,6 +415,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
braces_stack[1]=""
|
||||
style=reserved-word
|
||||
(( next_word = next_word | 16 ))
|
||||
elif [[ $arg == "[[" ]]; then
|
||||
braces_stack='A'"$braces_stack"
|
||||
fi
|
||||
;;
|
||||
'suffix alias') style=suffix-alias;;
|
||||
|
@ -500,10 +502,16 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
case $arg in
|
||||
']]')
|
||||
style=reserved-word
|
||||
[[ $braces_stack[1] == "A" ]] && braces_stack[1]=""
|
||||
;;
|
||||
']')
|
||||
style=builtin
|
||||
;;
|
||||
$'\x28')
|
||||
# '(' inside [[
|
||||
style=reserved-word
|
||||
braces_stack='R'"$braces_stack"
|
||||
;;
|
||||
$'\x29') # subshell or end of array assignment
|
||||
if (( in_array_assignment )); then
|
||||
style=assign
|
||||
|
@ -584,6 +592,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
if [[ $arg == ';' ]] && (( in_array_assignment )); then
|
||||
# literal newline inside an array assignment
|
||||
(( next_word = 2 ))
|
||||
elif [[ -n "${braces_stack[(r)A]}" ]]; then
|
||||
(( next_word = 2 ))
|
||||
else
|
||||
(( next_word = 1 ))
|
||||
highlight_glob=1
|
||||
|
@ -606,6 +616,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
# This is the default/common codepath.
|
||||
(( in_redirection == 0 )) && (( this_word = next_word )) #else # Stall $this_word.
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check if $arg is a path.
|
||||
|
|
Loading…
Reference in a new issue