command word: Start fixing issue #207, "Word following certain reserved words should be a command word".

This commit is contained in:
Daniel Shahaf
2015-10-28 08:04:43 +02:00
parent 87deac3062
commit b397b12ac1
2 changed files with 15 additions and 4 deletions

View File

@@ -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