mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-12-04 21:56:45 +01:00
command word: Start fixing issue #207, "Word following certain reserved words should be a command word".
This commit is contained in:
parent
87deac3062
commit
b397b12ac1
2 changed files with 15 additions and 4 deletions
|
|
@ -87,6 +87,7 @@ _zsh_highlight_main_highlighter()
|
|||
local start_pos=0 end_pos highlight_glob=true arg style
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
|
||||
local buf="$PREBUFFER$BUFFER"
|
||||
region_highlight=()
|
||||
|
||||
|
|
@ -97,6 +98,15 @@ _zsh_highlight_main_highlighter()
|
|||
'builtin' 'command' 'exec' 'nocorrect' 'noglob'
|
||||
)
|
||||
|
||||
# Tokens that, at (naively-determined) "command position", are followed by
|
||||
# a de jure command position.
|
||||
ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW=(
|
||||
'while'
|
||||
'if'
|
||||
'then'
|
||||
'do'
|
||||
)
|
||||
|
||||
# State machine
|
||||
#
|
||||
# The states are:
|
||||
|
|
@ -284,6 +294,7 @@ _zsh_highlight_main_highlighter()
|
|||
# TODO maybe check *':regular:'* here?
|
||||
next_word=':start:'
|
||||
elif
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:' ]] ||
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:' ]]; then
|
||||
next_word=':start:'
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue