@@ -306,9 +306,13 @@ _zsh_highlight_highlighter_main_paint()
306
306
# $flags_sans_argument is a set of letters, corresponding to the option letters
307
307
# that wouldn't be followed by a colon in a getopts specification.
308
308
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.)
312
316
#
313
317
# Currently, setting $flags_sans_argument is only important for commands that
314
318
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
@@ -726,6 +730,17 @@ _zsh_highlight_main_highlighter_highlight_list()
726
730
this_word= ' :sudo_opt:'
727
731
next_word+= ' :start:'
728
732
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
729
744
elif [[ $arg == ' -' * ]]; then
730
745
# Unknown flag. We don't know whether it takes an argument or not,
731
746
# so modify $next_word as we do for flags that require no argument.
@@ -804,6 +819,7 @@ _zsh_highlight_main_highlighter_highlight_list()
804
819
set -- " ${(@ s.: .)precommand_options[$arg]} "
805
820
flags_with_argument=$1
806
821
flags_sans_argument=$2
822
+ flags_solo=$3
807
823
}
808
824
next_word=${next_word//: regular:/ }
809
825
next_word+=' :sudo_opt:'
0 commit comments