@@ -7,7 +7,7 @@ use std::{
77
88use icu:: collator:: CollatorBorrowed ;
99use rayon:: {
10- iter:: { IntoParallelRefMutIterator , ParallelBridge , ParallelExtend , ParallelIterator } ,
10+ iter:: { ParallelBridge , ParallelExtend , ParallelIterator } ,
1111 slice:: ParallelSliceMut ,
1212} ;
1313
@@ -125,63 +125,6 @@ impl TabData {
125125 // }
126126 }
127127
128- #[ allow( dead_code) ]
129- fn read_dir_filter ( & mut self ) {
130- let case_sensitive = self
131- . search
132- . as_ref ( )
133- . is_some_and ( |search| search. case_sensitive ) ;
134- let search = self
135- . search
136- . as_ref ( )
137- . map ( |search| search. value . as_str ( ) )
138- . unwrap_or_default ( ) ;
139- let search_len = search. len ( ) ;
140- let collator = build_collator ( case_sensitive) ;
141- let directories: & [ PathBuf ] = match & self . current_path {
142- CurrentPath :: None => & [ ] ,
143- CurrentPath :: One ( path_buf) => std:: slice:: from_ref ( path_buf) ,
144- CurrentPath :: Multiple ( path_bufs) => path_bufs. as_slice ( ) ,
145- } ;
146-
147- let depth = self . search . as_ref ( ) . map_or ( 1 , |search| search. depth ) ;
148- self . list = directories
149- . iter ( )
150- . flat_map ( |d| {
151- walkdir:: WalkDir :: new ( d)
152- . follow_links ( true )
153- . max_depth ( depth)
154- . into_iter ( )
155- . flatten ( )
156- . skip ( 1 )
157- . filter_map ( |e| {
158- let s = e. file_name ( ) . to_string_lossy ( ) ;
159- if !self . show_hidden && ( s. starts_with ( '.' ) || s. starts_with ( '$' ) ) {
160- return None ;
161- }
162- if search_len > s. len ( ) {
163- return None ;
164- }
165- let chars = s. as_bytes ( ) ;
166- let mut found = false ;
167- for i in 0 ..=( s. len ( ) - search_len) {
168- if collator. compare_utf8 ( search. as_bytes ( ) , & chars[ i..i + search_len] )
169- == Ordering :: Equal
170- {
171- found = true ;
172- break ;
173- }
174- }
175- if !found {
176- return None ;
177- }
178- e. try_into ( ) . ok ( )
179- } )
180- . collect :: < Vec < crate :: data:: files:: DirEntry > > ( )
181- } )
182- . collect ( ) ;
183- }
184-
185128 // pub fn get_visible_entries(&self) -> impl Iterator<Item = &DirEntry> {
186129 // self.visible_entries.iter().map(|&idx| &self.list[idx])
187130 // }
@@ -205,34 +148,40 @@ impl TabData {
205148 let search_len = search. len ( ) ;
206149 let collator = build_collator ( case_sensitive) ;
207150 for ( i, entry) in self . list . iter ( ) . enumerate ( ) {
208- let mut visible = true ;
209151 if !self . show_hidden {
210152 let name = entry. get_splitted_path ( ) . 1 ;
211153 if name. starts_with ( "." ) || name. starts_with ( "$" ) {
212- visible = false ;
154+ continue ;
213155 }
214156 }
215157 if is_searching {
216158 let name = entry. get_splitted_path ( ) . 1 ;
217159 if search_len > name. len ( ) {
218- visible = false ;
219- } else {
220- let chars = name. as_bytes ( ) ;
221- let mut found = false ;
222- for i in 0 ..=( name. len ( ) - search_len) {
223- if collator. compare_utf8 ( search. as_bytes ( ) , & chars[ i..i + search_len] )
224- == Ordering :: Equal
225- {
226- found = true ;
227- break ;
228- }
160+ continue ;
161+ }
162+ let chars = name. as_bytes ( ) ;
163+ let mut found = false ;
164+ for i in 0 ..=( name. len ( ) - search_len) {
165+ if collator. compare_utf8 ( search. as_bytes ( ) , & chars[ i..i + search_len] )
166+ == Ordering :: Equal
167+ {
168+ found = true ;
169+ log:: error!(
170+ "MATCH: {}" ,
171+ name[ i..i + search_len] . escape_debug( ) . to_string( )
172+ ) ;
173+ break ;
174+ }
175+ }
176+ if !found {
177+ if name. contains ( search) {
178+ log:: error!( "WTF: {}" , name) ;
179+ } else {
180+ continue ;
229181 }
230- visible &= found;
231182 }
232183 }
233- if visible {
234- self . visible_entries . push ( i) ;
235- }
184+ self . visible_entries . push ( i) ;
236185 }
237186 }
238187
@@ -267,8 +216,18 @@ impl TabData {
267216 }
268217 CurrentPath :: Multiple ( path_bufs) => path_bufs. as_slice ( ) ,
269218 } ;
270-
219+ let depth = self . search . as_ref ( ) . map_or ( 1 , |search| search. depth ) ;
220+ eprintln ! ( "DEPTH: {}" , depth) ;
271221 for d in directories {
222+ self . list . extend (
223+ walkdir:: WalkDir :: new ( d)
224+ . follow_links ( true )
225+ . max_depth ( depth)
226+ . into_iter ( )
227+ . flatten ( )
228+ . skip ( 1 )
229+ . filter_map ( |e| e. try_into ( ) . ok ( ) ) ,
230+ ) ;
272231 let paths = {
273232 #[ cfg( feature = "profiling" ) ]
274233 puffin:: profile_scope!( "lwa_fm::dir_handling::read_dir::with_hidden::dir" ) ;
@@ -285,8 +244,6 @@ impl TabData {
285244 e. try_into ( ) . ok ( )
286245 } ) ) ;
287246 }
288-
289- self . list . par_iter_mut ( ) . for_each ( |e| e. read_metadata ( ) ) ;
290247 }
291248
292249 pub fn sort_entries ( & mut self , sort_settings : & DirectoryViewSettings ) {
0 commit comments