Merge remote-tracking branch 'danielsh/whitespace-historical'

* danielsh/whitespace-historical:
  Fix historical instances of one-space indentation.
This commit is contained in:
Daniel Shahaf 2020-03-17 17:08:06 +00:00
commit 0f627fdf60

View File

@ -782,75 +782,75 @@ _zsh_highlight_main_highlighter_highlight_list()
next_word+=':sudo_opt:' next_word+=':sudo_opt:'
next_word+=':start:' next_word+=':start:'
fi fi
fi fi
# The Great Fork: is this a command word? Is this a non-command word? # The Great Fork: is this a command word? Is this a non-command word?
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
# First, determine the style of the command separator itself. # First, determine the style of the command separator itself.
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
# Missing closing square bracket(s) # Missing closing square bracket(s)
style=unknown-token style=unknown-token
elif $in_array_assignment; then elif $in_array_assignment; then
case $arg in case $arg in
# Literal newlines are just fine. # Literal newlines are just fine.
($'\n') style=commandseparator;; ($'\n') style=commandseparator;;
# Semicolons are parsed the same way as literal newlines. Nevertheless, # Semicolons are parsed the same way as literal newlines. Nevertheless,
# highlight them as errors since they're probably unintended. Compare # highlight them as errors since they're probably unintended. Compare
# issue #691. # issue #691.
(';') style=unknown-token;; (';') style=unknown-token;;
# Other command separators aren't allowed. # Other command separators aren't allowed.
(*) style=unknown-token;; (*) style=unknown-token;;
esac esac
elif [[ $this_word == *':regular:'* ]]; then elif [[ $this_word == *':regular:'* ]]; then
style=commandseparator style=commandseparator
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
style=commandseparator style=commandseparator
else else
# This highlights empty commands (semicolon follows nothing) as an error. # This highlights empty commands (semicolon follows nothing) as an error.
# Zsh accepts them, though. # Zsh accepts them, though.
style=unknown-token style=unknown-token
fi
# Second, determine the style of next_word.
if [[ $arg == $'\n' ]] && $in_array_assignment; then
# literal newline inside an array assignment
next_word=':regular:'
elif [[ $arg == ';' ]] && $in_array_assignment; then
# literal semicolon inside an array assignment
next_word=':regular:'
else
next_word=':start:'
highlight_glob=true
if [[ $arg != '|' && $arg != '|&' ]]; then
next_word+=':start_of_pipeline:'
fi
fi
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
# try-always construct
style=reserved-word # de facto a reserved word, although not de jure
highlight_glob=true
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
style=precommand
() {
set -- "${(@s.:.)precommand_options[$arg]}"
flags_with_argument=$1
flags_sans_argument=$2
flags_solo=$3
}
next_word=${next_word//:regular:/}
next_word+=':sudo_opt:'
next_word+=':start:'
if [[ $arg == 'exec' ]]; then
# To allow "exec 2>&1;" where there's no command word
next_word+=':regular:'
fi fi
else
case $res in # Second, determine the style of next_word.
reserved) # reserved word if [[ $arg == $'\n' ]] && $in_array_assignment; then
# literal newline inside an array assignment
next_word=':regular:'
elif [[ $arg == ';' ]] && $in_array_assignment; then
# literal semicolon inside an array assignment
next_word=':regular:'
else
next_word=':start:'
highlight_glob=true
if [[ $arg != '|' && $arg != '|&' ]]; then
next_word+=':start_of_pipeline:'
fi
fi
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
# try-always construct
style=reserved-word # de facto a reserved word, although not de jure
highlight_glob=true
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
style=precommand
() {
set -- "${(@s.:.)precommand_options[$arg]}"
flags_with_argument=$1
flags_sans_argument=$2
flags_solo=$3
}
next_word=${next_word//:regular:/}
next_word+=':sudo_opt:'
next_word+=':start:'
if [[ $arg == 'exec' ]]; then
# To allow "exec 2>&1;" where there's no command word
next_word+=':regular:'
fi
else
case $res in
(reserved) # reserved word
style=reserved-word style=reserved-word
# Match braces and handle special cases. # Match braces and handle special cases.
case $arg in case $arg in
@ -927,15 +927,17 @@ _zsh_highlight_main_highlighter_highlight_list()
;; ;;
esac esac
;; ;;
'suffix alias') style=suffix-alias;; ('suffix alias')
alias) :;; style=suffix-alias
builtin) style=builtin ;;
(alias) :;;
(builtin) style=builtin
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack" [[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
;; ;;
function) style=function;; (function) style=function;;
command) style=command;; (command) style=command;;
hashed) style=hashed-command;; (hashed) style=hashed-command;;
none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then (none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
local i=$(( arg[(i)=] + 1 )) local i=$(( arg[(i)=] + 1 ))
if [[ $arg[i] == '(' ]]; then if [[ $arg[i] == '(' ]]; then
@ -1004,67 +1006,70 @@ _zsh_highlight_main_highlighter_highlight_list()
fi fi
fi fi
;; ;;
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res (*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
continue continue
;; ;;
esac esac
fi fi
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
next_word=':start::start_of_pipeline:' next_word=':start::start_of_pipeline:'
fi fi
else # $arg is a non-command word else # $arg is a non-command word
case $arg in case $arg in
$'\x29') # subshell or end of array assignment ($'\x29')
if $in_array_assignment; then # subshell or end of array assignment
style=assign if $in_array_assignment; then
in_array_assignment=false style=assign
next_word+=':start:' in_array_assignment=false
elif (( in_redirection )); then next_word+=':start:'
style=unknown-token elif (( in_redirection )); then
else style=unknown-token
if _zsh_highlight_main__stack_pop 'S'; then else
REPLY=$start_pos if _zsh_highlight_main__stack_pop 'S'; then
reply=($list_highlights) REPLY=$start_pos
return 0 reply=($list_highlights)
fi return 0
_zsh_highlight_main__stack_pop 'R' reserved-word fi
fi;; _zsh_highlight_main__stack_pop 'R' reserved-word
$'\x28\x29') # possibly a function definition fi
if (( in_redirection )) || $in_array_assignment; then ;;
style=unknown-token ($'\x28\x29')
else # possibly a function definition
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word if (( in_redirection )) || $in_array_assignment; then
then style=unknown-token
next_word+=':start::start_of_pipeline:' else
fi if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
style=reserved-word then
fi next_word+=':start::start_of_pipeline:'
;; fi
*) if false; then style=reserved-word
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then fi
# Parsing rule: { ;;
# (*) if false; then
# Additionally, `tt(})' is recognized in any position if neither the elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set. # Parsing rule: {
if (( in_redirection )) || $in_array_assignment; then #
style=unknown-token # Additionally, `tt(})' is recognized in any position if neither the
else # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
_zsh_highlight_main__stack_pop 'Y' reserved-word if (( in_redirection )) || $in_array_assignment; then
if [[ $style == reserved-word ]]; then style=unknown-token
next_word+=':always:' else
fi _zsh_highlight_main__stack_pop 'Y' reserved-word
fi if [[ $style == reserved-word ]]; then
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then next_word+=':always:'
style=history-expansion fi
elif [[ $arg == $'\x5d\x5d' ]] && _zsh_highlight_main__stack_pop 'T' reserved-word; then fi
: elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then style=history-expansion
: elif [[ $arg == $'\x5d\x5d' ]] && _zsh_highlight_main__stack_pop 'T' reserved-word; then
else :
_zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection )) elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then
continue :
fi else
;; _zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection ))
continue
fi
;;
esac esac
fi fi
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
@ -1341,14 +1346,14 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
(( j = i + start_pos - 1 )) (( j = i + start_pos - 1 ))
(( k = j + 1 )) (( k = j + 1 ))
case "$arg[$i]" in case "$arg[$i]" in
'"') break;; ('"') break;;
'`') saved_reply=($reply) ('`') saved_reply=($reply)
_zsh_highlight_main_highlighter_highlight_backtick $i _zsh_highlight_main_highlighter_highlight_backtick $i
(( i = REPLY )) (( i = REPLY ))
reply=($saved_reply $reply) reply=($saved_reply $reply)
continue continue
;; ;;
'$' ) style=dollar-double-quoted-argument ('$') style=dollar-double-quoted-argument
# Look for an alphanumeric parameter name. # Look for an alphanumeric parameter name.
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
(( k += $#MATCH )) # highlight the parameter name (( k += $#MATCH )) # highlight the parameter name