From 8b4adbd991b0329edda7a8a40fef859b56192f70 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 28 Oct 2015 14:57:26 +0200 Subject: [PATCH] Fix issue #222, "command word after repeat". --- highlighters/main/main-highlighter.zsh | 8 ++++++++ highlighters/main/test-data/control-flow.zsh | 2 +- highlighters/main/test-data/reserved-word.zsh | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 7d4410d..5079f50 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -342,6 +342,14 @@ _zsh_highlight_main_highlighter() [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:' ]] || [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:' ]]; then next_word=':start:' + elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then + # skip the repeat-count word + in_redirection=2 + # The redirection mechanism assumes $this_word describes the word + # following the redirection. Make it so. + # + # The repeat-count word will be handled like a redirection target. + this_word=':start:' fi [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] && highlight_glob=true start_pos=$end_pos diff --git a/highlighters/main/test-data/control-flow.zsh b/highlighters/main/test-data/control-flow.zsh index 7e61372..3107f50 100644 --- a/highlighters/main/test-data/control-flow.zsh +++ b/highlighters/main/test-data/control-flow.zsh @@ -47,5 +47,5 @@ expected_region_highlight+=( "54 56 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "x" "59 62 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done "65 70 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat - "75 76 $ZSH_HIGHLIGHT_STYLES[command] 'issue #222'" # ls + "75 76 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) diff --git a/highlighters/main/test-data/reserved-word.zsh b/highlighters/main/test-data/reserved-word.zsh index b19af50..2f62103 100644 --- a/highlighters/main/test-data/reserved-word.zsh +++ b/highlighters/main/test-data/reserved-word.zsh @@ -33,6 +33,6 @@ BUFFER='repeat "1" do done' expected_region_highlight=( "1 6 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat "8 10 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "1" - "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word] 'issue #222'" # do - "15 18 $ZSH_HIGHLIGHT_STYLES[reserved-word] 'fallout of previous test point'" # done + "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # do + "15 18 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done )