File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,10 @@ pub(crate) fn complete_path(
259
259
} ;
260
260
debug ! ( "complete_path: search_root={search_root:?}, prefix={prefix:?}" ) ;
261
261
262
+ if value_os. is_empty ( ) && is_wanted ( & search_root) {
263
+ completions. push ( "." . into ( ) ) ;
264
+ }
265
+
262
266
for entry in std:: fs:: read_dir ( & search_root)
263
267
. ok ( )
264
268
. into_iter ( )
Original file line number Diff line number Diff line change @@ -616,6 +616,41 @@ d_dir/
616
616
) ;
617
617
}
618
618
619
+ #[ test]
620
+ fn suggest_value_path_dir ( ) {
621
+ let testdir = snapbox:: dir:: DirRoot :: mutable_temp ( ) . unwrap ( ) ;
622
+ let testdir_path = testdir. path ( ) . unwrap ( ) ;
623
+ fs:: write ( testdir_path. join ( "a_file" ) , "" ) . unwrap ( ) ;
624
+ fs:: write ( testdir_path. join ( "b_file" ) , "" ) . unwrap ( ) ;
625
+ fs:: create_dir_all ( testdir_path. join ( "c_dir" ) ) . unwrap ( ) ;
626
+ fs:: create_dir_all ( testdir_path. join ( "d_dir" ) ) . unwrap ( ) ;
627
+
628
+ let mut cmd = Command :: new ( "dynamic" )
629
+ . arg (
630
+ clap:: Arg :: new ( "input" )
631
+ . long ( "input" )
632
+ . short ( 'i' )
633
+ . add ( ArgValueCompleter :: new (
634
+ PathCompleter :: dir ( ) . current_dir ( testdir_path. to_owned ( ) ) ,
635
+ ) ) ,
636
+ )
637
+ . args_conflicts_with_subcommands ( true ) ;
638
+
639
+ assert_data_eq ! (
640
+ complete!( cmd, "--input [TAB]" , current_dir = Some ( testdir_path) ) ,
641
+ snapbox:: str ![ [ r#"
642
+ .
643
+ c_dir/
644
+ d_dir/
645
+ "# ] ] ,
646
+ ) ;
647
+
648
+ assert_data_eq ! (
649
+ complete!( cmd, "--input c[TAB]" , current_dir = Some ( testdir_path) ) ,
650
+ snapbox:: str ![ "c_dir/" ] ,
651
+ ) ;
652
+ }
653
+
619
654
#[ test]
620
655
fn suggest_custom_arg_value ( ) {
621
656
fn custom_completer ( ) -> Vec < CompletionCandidate > {
You can’t perform that action at this time.
0 commit comments