mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-12-04 21:56:45 +01:00
'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
Merge remote-tracking branch 'upstream/pr/331' * upstream/pr/331: 'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
This commit is contained in:
commit
e35a0b256e
4 changed files with 9 additions and 4 deletions
|
|
@ -273,6 +273,7 @@ _zsh_highlight_main_highlighter()
|
|||
# which add the entry early so escape sequences within the string override
|
||||
# the string's color.
|
||||
integer already_added=0
|
||||
style=unknown-token
|
||||
if [[ $this_word == *':start:'* ]]; then
|
||||
in_array_assignment=false
|
||||
if [[ $arg == 'noglob' ]]; then
|
||||
|
|
@ -468,12 +469,16 @@ _zsh_highlight_main_highlighter()
|
|||
;;
|
||||
esac
|
||||
fi
|
||||
else # $arg is a non-command word
|
||||
fi
|
||||
if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath
|
||||
{ (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] }
|
||||
then # $arg is a non-command word
|
||||
case $arg in
|
||||
$'\x29') # subshell or end of array assignment
|
||||
if $in_array_assignment; then
|
||||
style=assign
|
||||
in_array_assignment=false
|
||||
next_word+=':start:'
|
||||
else
|
||||
style=reserved-word
|
||||
fi;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue