diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 5d108acc9..9bf0e3a82 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -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 diff --git a/highlighters/main/test-data/alias-comment1.zsh b/highlighters/main/test-data/alias-comment1.zsh index 861857551..bae7ef6f7 100644 --- a/highlighters/main/test-data/alias-comment1.zsh +++ b/highlighters/main/test-data/alias-comment1.zsh @@ -33,5 +33,5 @@ alias x=$'# foo\npwd' BUFFER='x' expected_region_highlight=( - '1 1 alias "issue #677"' # x + '1 1 alias' # x )