'main': Highlight mismatched 'if'/'fi'.
Also 'then'/'elif'/'else'.
This commit is contained in:
@@ -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"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user