From 9134cdf8d6a87500ccd5b01df0bd46e22d6744c3 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 15 Mar 2020 14:59:07 +0000 Subject: [PATCH] 'main': Allow newlines in command position. Fixes #501. Fixes #616 (the original form; not the form in test-data/alias-comment1.zsh which is now considered o be #677 (see previous commit for details)). Fixes a latent bug in test-data/always2.zsh. No user-visible effect, and therefore, no changelog entry. --- highlighters/main/main-highlighter.zsh | 6 ++++-- highlighters/main/test-data/always2.zsh | 2 +- highlighters/main/test-data/comment-followed.zsh | 2 +- highlighters/main/test-data/empty-command-newline.zsh | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 66ebff5..6f09f09 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -747,10 +747,12 @@ _zsh_highlight_main_highlighter_highlight_list() (*) style=unknown-token;; esac elif [[ $this_word == *':regular:'* ]]; then - # This highlights empty commands (semicolon follows nothing) as an error. - # Zsh accepts them, though. + style=commandseparator + elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then style=commandseparator else + # This highlights empty commands (semicolon follows nothing) as an error. + # Zsh accepts them, though. style=unknown-token fi diff --git a/highlighters/main/test-data/always2.zsh b/highlighters/main/test-data/always2.zsh index f5852c6..991137c 100644 --- a/highlighters/main/test-data/always2.zsh +++ b/highlighters/main/test-data/always2.zsh @@ -32,7 +32,7 @@ BUFFER=$'{\nls\n} always { pwd }' expected_region_highlight=( '1 1 reserved-word' # { - '2 2 unknown-token' # \n + '2 2 commandseparator' # \n '3 4 command' # ls '5 5 commandseparator' # \n '6 6 reserved-word' # } diff --git a/highlighters/main/test-data/comment-followed.zsh b/highlighters/main/test-data/comment-followed.zsh index 6f5a4f5..044f283 100644 --- a/highlighters/main/test-data/comment-followed.zsh +++ b/highlighters/main/test-data/comment-followed.zsh @@ -34,6 +34,6 @@ BUFFER=$'# foo\ntrue' expected_region_highlight=( '1 5 comment' # # foo - '6 6 commandseparator "issue #501"' # \n + '6 6 commandseparator' # \n '7 10 builtin' # true ) diff --git a/highlighters/main/test-data/empty-command-newline.zsh b/highlighters/main/test-data/empty-command-newline.zsh index 783f4b6..4b7b35c 100644 --- a/highlighters/main/test-data/empty-command-newline.zsh +++ b/highlighters/main/test-data/empty-command-newline.zsh @@ -34,6 +34,6 @@ BUFFER=$':;\n:' expected_region_highlight=( '1 1 builtin' # : '2 2 commandseparator' # ; - '3 3 commandseparator "issue #616"' # \n + '3 3 commandseparator' # \n '4 4 builtin' # : )