@@ -306,9 +306,13 @@ _zsh_highlight_highlighter_main_paint()
306306 # $flags_sans_argument is a set of letters, corresponding to the option letters
307307 # that wouldn't be followed by a colon in a getopts specification.
308308 local flags_sans_argument
309- # $precommand_options maps precommand name to values of $flags_with_argument and
310- # $flags_sans_argument for that precommand, joined by a colon. (The value is NOT
311- # a getopt(3) spec, although it resembles one.)
309+ # $flags_solo is a set of letters, corresponding to option letters that, if
310+ # present, mean the precommand will now be acting as a precommand, i.e., will
311+ # not be followed by a :start: word.
312+ local flags_solo
313+ # $precommand_options maps precommand name to values of $flags_with_argument,
314+ # $flags_sans_argument, and flags_solo for that precommand, joined by a
315+ # colon. (The value is NOT a getopt(3) spec, although it resembles one.)
312316 #
313317 # Currently, setting $flags_sans_argument is only important for commands that
314318 # have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
@@ -726,6 +730,17 @@ _zsh_highlight_main_highlighter_highlight_list()
726730 this_word= ' :sudo_opt:'
727731 next_word+= ' :start:'
728732 next_word+= ' :sudo_opt:'
733+ elif [[ -n $flags_solo ]] &&
734+ {
735+ # Trenary
736+ if [[ -n $flags_sans_argument ]]
737+ then [[ $arg == ' -' [$flags_sans_argument ]# [$flags_solo]* ]]
738+ else [[ $arg == ' -' [$flags_solo ]* ]]
739+ fi
740+ } then
741+ # Solo flags
742+ this_word= ' :sudo_opt:'
743+ next_word= ' :regular:' # no :start:, nor :sudo_opt: since we don't know whether the solo flag takes an argument or not
729744 elif [[ $arg == ' -' * ]]; then
730745 # Unknown flag. We don't know whether it takes an argument or not,
731746 # so modify $next_word as we do for flags that require no argument.
@@ -804,6 +819,7 @@ _zsh_highlight_main_highlighter_highlight_list()
804819 set -- " ${(@ s.: .)precommand_options[$arg]} "
805820 flags_with_argument=$1
806821 flags_sans_argument=$2
822+ flags_solo=$3
807823 }
808824 next_word=${next_word//: regular:/ }
809825 next_word+=' :sudo_opt:'
0 commit comments