File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -620,32 +620,39 @@ impl Explorer {
620
620
621
621
pub fn find_entries_with_initial ( & self , initial : char ) -> Option < FilteredEntries > {
622
622
let parent_dir_entry = parent_dir_entry ( ) ;
623
- let initial_lower = initial. to_ascii_lowercase ( ) as u8 ; // Avoid recalculating this for each item
624
-
623
+ let initial_lower = initial. to_lowercase ( ) . next ( ) ; // Get the first character after lowercasing
624
+
625
+ // If initial_lower is None (rare, but possible), return None early
626
+ let initial_lower = match initial_lower {
627
+ Some ( c) => c,
628
+ None => return None ,
629
+ } ;
630
+
625
631
let entries: Vec < _ > = self
626
632
. items
627
633
. iter ( )
628
634
. filter ( |item| !item. name . starts_with ( & parent_dir_entry) ) // Remove parent directory entry
629
635
. enumerate ( ) // Attach indices to items
630
636
. filter_map ( |( index, item) | {
631
637
item. name
632
- . as_bytes ( )
633
- . first ( )
634
- . map ( | & c| c. to_ascii_lowercase ( ) ) // Get first character efficiently
638
+ . chars ( )
639
+ . next ( ) // Get the first character of the name
640
+ . and_then ( | c| c. to_lowercase ( ) . next ( ) ) // Lowercase and get the first character
635
641
. filter ( |& c| c == initial_lower) // Compare without case sensitivity
636
642
. map ( |_| match self . cwd . parent ( ) {
637
643
Some ( _) => index + 1 , // Adjust index if parent exists
638
644
None => index,
639
645
} )
640
646
} )
641
647
. collect ( ) ;
642
-
648
+
643
649
if entries. is_empty ( ) {
644
650
None
645
651
} else {
646
652
Some ( FilteredEntries :: new ( initial, entries) )
647
653
}
648
654
}
655
+
649
656
650
657
pub fn find_entries_by_name (
651
658
tx : UnboundedSender < Action > ,
You can’t perform that action at this time.
0 commit comments