Skip to content

Commit

Permalink
'main': Fix issue #677, concerning multiline aliases.
Browse files Browse the repository at this point in the history
The fix is to exempt such aliases from the empty commands sanity check.
  • Loading branch information
danielshahaf committed May 22, 2020
1 parent 8211a95 commit cf1d58e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,17 @@ _zsh_highlight_main_highlighter_highlight_list()
style=commandseparator
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
style=commandseparator
elif [[ $this_word == *':start:'* ]] && [[ $arg == ';' ]] && (( in_alias )); then
style=commandseparator
else
# This highlights empty commands (semicolon follows nothing) as an error.
# Zsh accepts them, though.
# Empty commands (semicolon follows nothing) are valid syntax.
# However, in interactive use they are likely to be erroneous;
# therefore, we highlight them as errors.
#
# Alias definitions are exempted from this check to allow multiline aliases
# with explicit (redundant) semicolons: «alias foo=$'bar;\nbaz'» (issue #677).
#
# See also #691 about possibly changing the style used here.
style=unknown-token
fi

Expand Down
2 changes: 1 addition & 1 deletion highlighters/main/test-data/alias-comment1.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ alias x=$'# foo\npwd'
BUFFER='x'

expected_region_highlight=(
'1 1 alias "issue #677"' # x
'1 1 alias' # x
)

0 comments on commit cf1d58e

Please sign in to comment.