Skip to content

Commit b454b59

Browse files
committed
Fix historical instances of one-space indentation.
No functional change.
1 parent e815d45 commit b454b59

File tree

1 file changed

+147
-142
lines changed

1 file changed

+147
-142
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 147 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -762,75 +762,75 @@ _zsh_highlight_main_highlighter_highlight_list()
762762
next_word+=':sudo_opt:'
763763
next_word+=':start:'
764764
fi
765-
fi
766-
767-
# The Great Fork: is this a command word? Is this a non-command word?
768-
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
769-
770-
# First, determine the style of the command separator itself.
771-
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
772-
# Missing closing square bracket(s)
773-
style=unknown-token
774-
elif $in_array_assignment; then
775-
case $arg in
776-
# Literal newlines are just fine.
777-
($'\n') style=commandseparator;;
778-
# Semicolons are parsed the same way as literal newlines. Nevertheless,
779-
# highlight them as errors since they're probably unintended. Compare
780-
# issue #691.
781-
(';') style=unknown-token;;
782-
# Other command separators aren't allowed.
783-
(*) style=unknown-token;;
784-
esac
785-
elif [[ $this_word == *':regular:'* ]]; then
786-
style=commandseparator
787-
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
788-
style=commandseparator
789-
else
790-
# This highlights empty commands (semicolon follows nothing) as an error.
791-
# Zsh accepts them, though.
792-
style=unknown-token
793-
fi
794-
795-
# Second, determine the style of next_word.
796-
if [[ $arg == $'\n' ]] && $in_array_assignment; then
797-
# literal newline inside an array assignment
798-
next_word=':regular:'
799-
elif [[ $arg == ';' ]] && $in_array_assignment; then
800-
# literal semicolon inside an array assignment
801-
next_word=':regular:'
802-
else
803-
next_word=':start:'
804-
highlight_glob=true
805-
if [[ $arg != '|' && $arg != '|&' ]]; then
806-
next_word+=':start_of_pipeline:'
807-
fi
808-
fi
809-
810-
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
811-
# try-always construct
812-
style=reserved-word # de facto a reserved word, although not de jure
813-
highlight_glob=true
814-
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
815-
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
816-
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
817-
style=precommand
818-
() {
819-
set -- "${(@s.:.)precommand_options[$arg]}"
820-
flags_with_argument=$1
821-
flags_sans_argument=$2
822-
flags_solo=$3
823-
}
824-
next_word=${next_word//:regular:/}
825-
next_word+=':sudo_opt:'
826-
next_word+=':start:'
827-
if [[ $arg == 'exec' ]]; then
828-
# To allow "exec 2>&1;" where there's no command word
829-
next_word+=':regular:'
765+
fi
766+
767+
# The Great Fork: is this a command word? Is this a non-command word?
768+
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
769+
770+
# First, determine the style of the command separator itself.
771+
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
772+
# Missing closing square bracket(s)
773+
style=unknown-token
774+
elif $in_array_assignment; then
775+
case $arg in
776+
# Literal newlines are just fine.
777+
($'\n') style=commandseparator;;
778+
# Semicolons are parsed the same way as literal newlines. Nevertheless,
779+
# highlight them as errors since they're probably unintended. Compare
780+
# issue #691.
781+
(';') style=unknown-token;;
782+
# Other command separators aren't allowed.
783+
(*) style=unknown-token;;
784+
esac
785+
elif [[ $this_word == *':regular:'* ]]; then
786+
style=commandseparator
787+
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
788+
style=commandseparator
789+
else
790+
# This highlights empty commands (semicolon follows nothing) as an error.
791+
# Zsh accepts them, though.
792+
style=unknown-token
793+
fi
794+
795+
# Second, determine the style of next_word.
796+
if [[ $arg == $'\n' ]] && $in_array_assignment; then
797+
# literal newline inside an array assignment
798+
next_word=':regular:'
799+
elif [[ $arg == ';' ]] && $in_array_assignment; then
800+
# literal semicolon inside an array assignment
801+
next_word=':regular:'
802+
else
803+
next_word=':start:'
804+
highlight_glob=true
805+
if [[ $arg != '|' && $arg != '|&' ]]; then
806+
next_word+=':start_of_pipeline:'
807+
fi
830808
fi
831-
else
832-
case $res in
833-
reserved) # reserved word
809+
810+
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
811+
# try-always construct
812+
style=reserved-word # de facto a reserved word, although not de jure
813+
highlight_glob=true
814+
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
815+
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
816+
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
817+
style=precommand
818+
() {
819+
set -- "${(@s.:.)precommand_options[$arg]}"
820+
flags_with_argument=$1
821+
flags_sans_argument=$2
822+
flags_solo=$3
823+
}
824+
next_word=${next_word//:regular:/}
825+
next_word+=':sudo_opt:'
826+
next_word+=':start:'
827+
if [[ $arg == 'exec' ]]; then
828+
# To allow "exec 2>&1;" where there's no command word
829+
next_word+=':regular:'
830+
fi
831+
else
832+
case $res in
833+
(reserved) # reserved word
834834
style=reserved-word
835835
# Match braces and handle special cases.
836836
case $arg in
@@ -907,15 +907,17 @@ _zsh_highlight_main_highlighter_highlight_list()
907907
;;
908908
esac
909909
;;
910-
'suffix alias') style=suffix-alias;;
911-
alias) :;;
912-
builtin) style=builtin
910+
('suffix alias')
911+
style=suffix-alias
912+
;;
913+
(alias) :;;
914+
(builtin) style=builtin
913915
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
914916
;;
915-
function) style=function;;
916-
command) style=command;;
917-
hashed) style=hashed-command;;
918-
none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
917+
(function) style=function;;
918+
(command) style=command;;
919+
(hashed) style=hashed-command;;
920+
(none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
919921
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
920922
local i=$(( arg[(i)=] + 1 ))
921923
if [[ $arg[i] == '(' ]]; then
@@ -984,67 +986,70 @@ _zsh_highlight_main_highlighter_highlight_list()
984986
fi
985987
fi
986988
;;
987-
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
989+
(*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
988990
continue
989991
;;
990-
esac
991-
fi
992-
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
993-
next_word=':start::start_of_pipeline:'
994-
fi
995-
else # $arg is a non-command word
992+
esac
993+
fi
994+
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
995+
next_word=':start::start_of_pipeline:'
996+
fi
997+
else # $arg is a non-command word
996998
case $arg in
997-
$'\x29') # subshell or end of array assignment
998-
if $in_array_assignment; then
999-
style=assign
1000-
in_array_assignment=false
1001-
next_word+=':start:'
1002-
elif (( in_redirection )); then
1003-
style=unknown-token
1004-
else
1005-
if _zsh_highlight_main__stack_pop 'S'; then
1006-
REPLY=$start_pos
1007-
reply=($list_highlights)
1008-
return 0
1009-
fi
1010-
_zsh_highlight_main__stack_pop 'R' reserved-word
1011-
fi;;
1012-
$'\x28\x29') # possibly a function definition
1013-
if (( in_redirection )) || $in_array_assignment; then
1014-
style=unknown-token
1015-
else
1016-
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
1017-
then
1018-
next_word+=':start::start_of_pipeline:'
1019-
fi
1020-
style=reserved-word
1021-
fi
1022-
;;
1023-
*) if false; then
1024-
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
1025-
# Parsing rule: {
1026-
#
1027-
# Additionally, `tt(})' is recognized in any position if neither the
1028-
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
1029-
if (( in_redirection )) || $in_array_assignment; then
1030-
style=unknown-token
1031-
else
1032-
_zsh_highlight_main__stack_pop 'Y' reserved-word
1033-
if [[ $style == reserved-word ]]; then
1034-
next_word+=':always:'
1035-
fi
1036-
fi
1037-
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
1038-
style=history-expansion
1039-
elif [[ $arg == $'\x5d\x5d' ]] && _zsh_highlight_main__stack_pop 'T' reserved-word; then
1040-
:
1041-
elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then
1042-
:
1043-
else
1044-
_zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection ))
1045-
continue
1046-
fi
1047-
;;
999+
($'\x29')
1000+
# subshell or end of array assignment
1001+
if $in_array_assignment; then
1002+
style=assign
1003+
in_array_assignment=false
1004+
next_word+=':start:'
1005+
elif (( in_redirection )); then
1006+
style=unknown-token
1007+
else
1008+
if _zsh_highlight_main__stack_pop 'S'; then
1009+
REPLY=$start_pos
1010+
reply=($list_highlights)
1011+
return 0
1012+
fi
1013+
_zsh_highlight_main__stack_pop 'R' reserved-word
1014+
fi
1015+
;;
1016+
($'\x28\x29')
1017+
# possibly a function definition
1018+
if (( in_redirection )) || $in_array_assignment; then
1019+
style=unknown-token
1020+
else
1021+
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
1022+
then
1023+
next_word+=':start::start_of_pipeline:'
1024+
fi
1025+
style=reserved-word
1026+
fi
1027+
;;
1028+
(*) if false; then
1029+
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
1030+
# Parsing rule: {
1031+
#
1032+
# Additionally, `tt(})' is recognized in any position if neither the
1033+
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
1034+
if (( in_redirection )) || $in_array_assignment; then
1035+
style=unknown-token
1036+
else
1037+
_zsh_highlight_main__stack_pop 'Y' reserved-word
1038+
if [[ $style == reserved-word ]]; then
1039+
next_word+=':always:'
1040+
fi
1041+
fi
1042+
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
1043+
style=history-expansion
1044+
elif [[ $arg == $'\x5d\x5d' ]] && _zsh_highlight_main__stack_pop 'T' reserved-word; then
1045+
:
1046+
elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then
1047+
:
1048+
else
1049+
_zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection ))
1050+
continue
1051+
fi
1052+
;;
10481053
esac
10491054
fi
10501055
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
@@ -1202,7 +1207,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
12021207
(( i = REPLY ))
12031208
highlights+=($reply)
12041209
continue
1205-
elif [[ $arg[i+1] == $'\x28' ]]; then
1210+
elif [[ $arg[i+1] == $'\x28' ]]; then
12061211
start=$i
12071212
(( i += 2 ))
12081213
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
@@ -1310,14 +1315,14 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
13101315
(( j = i + start_pos - 1 ))
13111316
(( k = j + 1 ))
13121317
case "$arg[$i]" in
1313-
'"') break;;
1314-
'`') saved_reply=($reply)
1315-
_zsh_highlight_main_highlighter_highlight_backtick $i
1316-
(( i = REPLY ))
1317-
reply=($saved_reply $reply)
1318-
continue
1319-
;;
1320-
'$' ) style=dollar-double-quoted-argument
1318+
('"') break;;
1319+
('`') saved_reply=($reply)
1320+
_zsh_highlight_main_highlighter_highlight_backtick $i
1321+
(( i = REPLY ))
1322+
reply=($saved_reply $reply)
1323+
continue
1324+
;;
1325+
('$') style=dollar-double-quoted-argument
13211326
# Look for an alphanumeric parameter name.
13221327
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
13231328
(( k += $#MATCH )) # highlight the parameter name

0 commit comments

Comments
 (0)