@@ -1078,15 +1078,6 @@ impl<'cmd> Parser<'cmd> {
10781078 matcher. add_index_to ( arg. get_id ( ) , self . cur_idx . get ( ) ) ;
10791079 }
10801080
1081- // Increment or create the group "args"
1082- for group in self . cmd . groups_for_arg ( arg. get_id ( ) ) {
1083- matcher. add_val_to (
1084- & group,
1085- AnyValue :: new ( arg. get_id ( ) . clone ( ) ) ,
1086- OsString :: from ( arg. get_id ( ) . as_str ( ) ) ,
1087- ) ;
1088- }
1089-
10901081 Ok ( ( ) )
10911082 }
10921083
@@ -1499,20 +1490,15 @@ impl<'cmd> Parser<'cmd> {
14991490 self . remove_overrides ( arg, matcher) ;
15001491 }
15011492 matcher. start_custom_arg ( arg, source) ;
1502- for group in self . cmd . groups_for_arg ( arg. get_id ( ) ) {
1503- matcher. start_custom_group ( group, source) ;
1504- }
1505- }
1506-
1507- /// Increase occurrence of specific argument and the grouped arg it's in.
1508- fn start_occurrence_of_arg ( & self , matcher : & mut ArgMatcher , arg : & Arg ) {
1509- // With each new occurrence, remove overrides from prior occurrences
1510- self . remove_overrides ( arg, matcher) ;
1511-
1512- matcher. start_occurrence_of_arg ( arg) ;
1513- // Increment or create the group "args"
1514- for group in self . cmd . groups_for_arg ( arg. get_id ( ) ) {
1515- matcher. start_occurrence_of_group ( group) ;
1493+ if source. is_explicit ( ) {
1494+ for group in self . cmd . groups_for_arg ( arg. get_id ( ) ) {
1495+ matcher. start_custom_group ( group. clone ( ) , source) ;
1496+ matcher. add_val_to (
1497+ & group,
1498+ AnyValue :: new ( arg. get_id ( ) . clone ( ) ) ,
1499+ OsString :: from ( arg. get_id ( ) . as_str ( ) ) ,
1500+ ) ;
1501+ }
15161502 }
15171503 }
15181504}
@@ -1549,7 +1535,7 @@ impl<'cmd> Parser<'cmd> {
15491535 // Add the arg to the matches to build a proper usage string
15501536 if let Some ( ( name, _) ) = did_you_mean. as_ref ( ) {
15511537 if let Some ( arg) = self . cmd . get_keymap ( ) . get ( & name. as_ref ( ) ) {
1552- self . start_occurrence_of_arg ( matcher, arg) ;
1538+ self . start_custom_arg ( matcher, arg, ValueSource :: CommandLine ) ;
15531539 }
15541540 }
15551541
0 commit comments