@@ -1809,6 +1809,18 @@ fn analyze_silver_searcher(
18091809 index += 2 ;
18101810 continue ;
18111811 }
1812+ SilverSearcherShortOption :: OptionalNumericValueInline => { }
1813+ SilverSearcherShortOption :: OptionalNumericValueNext => {
1814+ if argv
1815+ . get ( index + 1 )
1816+ . is_some_and ( |value| looks_like_integer ( value. as_str ( ) ) )
1817+ {
1818+ index += 2 ;
1819+ } else {
1820+ index += 1 ;
1821+ }
1822+ continue ;
1823+ }
18121824 SilverSearcherShortOption :: ControlValueInline => { }
18131825 SilverSearcherShortOption :: ControlValueNext => {
18141826 index += 2 ;
@@ -1856,6 +1868,8 @@ enum SilverSearcherShortOption<'a> {
18561868 FileSearchRegexNext ,
18571869 PathToIgnoreInline ( & ' a str ) ,
18581870 PathToIgnoreNext ,
1871+ OptionalNumericValueInline ,
1872+ OptionalNumericValueNext ,
18591873 ControlValueInline ,
18601874 ControlValueNext ,
18611875}
@@ -1877,6 +1891,12 @@ fn parse_silver_searcher_short_option(token: &str) -> Option<SilverSearcherShort
18771891 return Some ( SilverSearcherShortOption :: FileSearchRegexNext ) ;
18781892 }
18791893 'G' => return Some ( SilverSearcherShortOption :: FileSearchRegexInline ) ,
1894+ 'A' | 'B' | 'C' if value. is_empty ( ) => {
1895+ return Some ( SilverSearcherShortOption :: OptionalNumericValueNext ) ;
1896+ }
1897+ 'A' | 'B' | 'C' => {
1898+ return Some ( SilverSearcherShortOption :: OptionalNumericValueInline ) ;
1899+ }
18801900 'm' if value. is_empty ( ) => return Some ( SilverSearcherShortOption :: ControlValueNext ) ,
18811901 'm' => return Some ( SilverSearcherShortOption :: ControlValueInline ) ,
18821902 'p' if value. is_empty ( ) => return Some ( SilverSearcherShortOption :: PathToIgnoreNext ) ,
@@ -3840,6 +3860,22 @@ mod tests {
38403860 ) ;
38413861 assert ! ( ag_with_long_value_flag. inputs. is_empty( ) ) ;
38423862
3863+ let ag_with_short_context_flag = analyze_argv (
3864+ & [
3865+ OsString :: from ( "ag" ) ,
3866+ OsString :: from ( "-A" ) ,
3867+ OsString :: from ( "2" ) ,
3868+ OsString :: from ( "TODO" ) ,
3869+ ] ,
3870+ cwd. path ( ) ,
3871+ )
3872+ . expect ( "analyze" ) ;
3873+ assert_eq ! (
3874+ ag_with_short_context_flag. adapter_ids,
3875+ vec![ CommandAdapterId :: SilverSearcher ]
3876+ ) ;
3877+ assert ! ( ag_with_short_context_flag. inputs. is_empty( ) ) ;
3878+
38433879 let ag_with_filename_pattern = analyze_argv (
38443880 & [
38453881 OsString :: from ( "ag" ) ,
0 commit comments