From 63bcd85dfaf5d4139f9edce69293807a1a3ee43e Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 16 Mar 2020 19:13:12 +0000 Subject: [PATCH] =?UTF-8?q?'main':=20Don't=20use=20=C2=ABfoo=20&&=20bar=20?= =?UTF-8?q?||=20baz=C2=BB=20where=20a=20trenary=20is=20more=20appropriate.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevents the baz pattern match from being attempted whenever the bar pattern match was tried and failed. --- highlighters/main/main-highlighter.zsh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 0a899d8..0b40b08 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -698,14 +698,24 @@ _zsh_highlight_main_highlighter_highlight_list() if (( ! in_redirection )); then if [[ $this_word == *':sudo_opt:'* ]]; then if [[ -n $flags_with_argument ]] && - { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] || - [[ $arg == '-'[$flags_with_argument] ]] }; then + { + # Trenary + if [[ -n $flags_sans_argument ]] + then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] + else [[ $arg == '-'[$flags_with_argument] ]] + fi + } then # Flag that requires an argument this_word=${this_word//:start:/} next_word=':sudo_arg:' elif [[ -n $flags_with_argument ]] && - { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] || - [[ $arg == '-'[$flags_with_argument]* ]] }; then + { + # Trenary + if [[ -n $flags_sans_argument ]] + then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] + else [[ $arg == '-'[$flags_with_argument]* ]] + fi + } then # Argument attached in the same word this_word=${this_word//:start:/} next_word+=':start:'