'main': Highlight mismatched 'if'/'fi'.

Also 'then'/'elif'/'else'.
This commit is contained in:
Daniel Shahaf
2017-03-05 17:33:36 +00:00
parent be083d7f37
commit 73cb832702
4 changed files with 162 additions and 0 deletions

View File

@@ -241,6 +241,8 @@ _zsh_highlight_highlighter_main_paint()
# "Y" for curly
# "D" for do/done
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
# ":" for 'then'
local braces_stack
if (( path_dirs_was_set )); then
@@ -509,6 +511,29 @@ _zsh_highlight_highlighter_main_paint()
('done')
_zsh_highlight_main__stack_pop 'D' style=reserved-word
;;
('if')
braces_stack=':?'"$braces_stack"
;;
('then')
_zsh_highlight_main__stack_pop ':' style=reserved-word
;;
('elif')
if [[ ${braces_stack[1]} == '?' ]]; then
braces_stack=':'"$braces_stack"
else
style=unknown-token
fi
;;
('else')
if [[ ${braces_stack[1]} == '?' ]]; then
:
else
style=unknown-token
fi
;;
('fi')
_zsh_highlight_main__stack_pop '?' ""
;;
('foreach')
braces_stack='$'"$braces_stack"
;;