From 9cb87473cca68568c5285634a151617d1e7ccc9e Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 28 Oct 2015 13:37:45 +0200 Subject: [PATCH] sudo: Tweak state computations. This causes the ':start:' state to be set in $next_word in iteration N-1, rather than to only be added to $this_word in iteration N. --- highlighters/main/main-highlighter.zsh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index f8d6ffa..382618f 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -192,11 +192,14 @@ _zsh_highlight_main_highlighter() '-'[Cgprtu]) this_word=${this_word//:start:/}; next_word=':sudo_arg:';; # This prevents misbehavior with sudo -u -otherargument - '-'*) next_word+=':sudo_opt:';; - *) this_word+=':start:';; + '-'*) this_word=${this_word//:start:/}; + next_word+=':start:'; + next_word+=':sudo_opt:';; + *) ;; esac elif [[ $this_word == *':sudo_arg:'* ]]; then next_word+=':sudo_opt:' + next_word+=':start:' fi fi @@ -205,8 +208,9 @@ _zsh_highlight_main_highlighter() style=$ZSH_HIGHLIGHT_STYLES[precommand] elif [[ "$arg" = "sudo" ]]; then style=$ZSH_HIGHLIGHT_STYLES[precommand] - next_word+=':sudo_opt:' next_word=${next_word//:regular:/} + next_word+=':sudo_opt:' + next_word+=':start:' else _zsh_highlight_main_highlighter_expand_path $arg local expanded_arg="$REPLY"