File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -979,6 +979,15 @@ impl<'a> PathData<'a> {
979979 PathDataDisplayName :: Custom ( ref cow) => cow,
980980 }
981981 }
982+
983+ fn file_name ( & self ) -> & OsStr {
984+ match self . display_name {
985+ PathDataDisplayName :: SelfReferential => {
986+ self . p_buf . file_name ( ) . unwrap_or ( self . p_buf . as_os_str ( ) )
987+ }
988+ PathDataDisplayName :: Custom ( ref cow) => cow,
989+ }
990+ }
982991}
983992
984993impl Colorable for PathData < ' _ > {
@@ -1477,8 +1486,8 @@ fn sort_entries(entries: &mut [PathData], config: &Config) {
14771486 Sort :: Name => entries. sort_unstable_by ( |a, b| a. display_name ( ) . cmp ( b. display_name ( ) ) ) ,
14781487 Sort :: Version => entries. sort_unstable_by ( |a, b| {
14791488 version_cmp (
1480- os_str_as_bytes_lossy ( a. path ( ) . as_os_str ( ) ) . as_ref ( ) ,
1481- os_str_as_bytes_lossy ( b. path ( ) . as_os_str ( ) ) . as_ref ( ) ,
1489+ os_str_as_bytes_lossy ( a. file_name ( ) ) . as_ref ( ) ,
1490+ os_str_as_bytes_lossy ( b. file_name ( ) ) . as_ref ( ) ,
14821491 )
14831492 . then ( a. path ( ) . cmp ( b. path ( ) ) )
14841493 } ) ,
Original file line number Diff line number Diff line change @@ -3661,7 +3661,7 @@ fn test_ls_version_sort() {
36613661 ) ;
36623662
36633663 let result = scene. ucmd ( ) . arg ( "-a1v" ) . succeeds ( ) ;
3664- expected. insert ( expected . len ( ) - 1 , ".." ) ;
3664+ expected. insert ( 0 , ".." ) ;
36653665 expected. insert ( 0 , "." ) ;
36663666 assert_eq ! (
36673667 result. stdout_str( ) . split( '\n' ) . collect:: <Vec <_>>( ) ,
You can’t perform that action at this time.
0 commit comments