diff --git a/src/app.rs b/src/app.rs index 66fb79d..e18d263 100644 --- a/src/app.rs +++ b/src/app.rs @@ -641,7 +641,12 @@ impl App { let location_opt = match term_opt { Some(term) => match &tab.location { Location::Path(path) | Location::Search(path, ..) => Some(( - Location::Search(path.to_path_buf(), term, Instant::now()), + Location::Search( + path.to_path_buf(), + term, + tab.config.show_hidden, + Instant::now(), + ), true, )), _ => None, diff --git a/src/dialog.rs b/src/dialog.rs index 323eda4..50a55f0 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -512,7 +512,12 @@ impl App { let location_opt = match term_opt { Some(term) => match &self.tab.location { Location::Path(path) | Location::Search(path, ..) => Some(( - Location::Search(path.to_path_buf(), term, Instant::now()), + Location::Search( + path.to_path_buf(), + term, + self.tab.config.show_hidden, + Instant::now(), + ), true, )), _ => None, diff --git a/src/tab.rs b/src/tab.rs index aece917..0675543 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -533,6 +533,7 @@ pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec { pub fn scan_search bool + Sync>( tab_path: &PathBuf, term: &str, + show_hidden: bool, callback: F, ) { if term.is_empty() { @@ -551,8 +552,9 @@ pub fn scan_search bool + Sync>( } }; - //TODO: do we want to ignore files? ignore::WalkBuilder::new(tab_path) + .standard_filters(false) + .hidden(!show_hidden) //TODO: only use this on supported targets .same_file_system(true) .build_parallel() @@ -864,7 +866,7 @@ pub enum Location { Network(String, String), Path(PathBuf), Recents, - Search(PathBuf, String, Instant), + Search(PathBuf, String, bool, Instant), Trash, } @@ -899,7 +901,9 @@ impl Location { Self::Desktop(path, display.clone(), *desktop_config) } Self::Path(..) => Self::Path(path), - Self::Search(_, term, ..) => Self::Search(path, term.clone(), Instant::now()), + Self::Search(_, term, show_hidden, _) => { + Self::Search(path, term.clone(), *show_hidden, Instant::now()) + } other => other.clone(), } } @@ -2580,8 +2584,17 @@ impl Tab { } } } - Message::ToggleShowHidden => self.config.show_hidden = !self.config.show_hidden, - + Message::ToggleShowHidden => { + self.config.show_hidden = !self.config.show_hidden; + if let Location::Search(path, term, ..) = &self.location { + cd = Some(Location::Search( + path.clone(), + term.clone(), + self.config.show_hidden, + Instant::now(), + )); + } + } Message::View(view) => { self.config.view = view; } @@ -4194,10 +4207,11 @@ impl Tab { } // Load search items incrementally - if let Location::Search(path, term, start) = &self.location { + if let Location::Search(path, term, show_hidden, start) = &self.location { let location = self.location.clone(); let path = path.clone(); let term = term.clone(); + let show_hidden = *show_hidden; let start = start.clone(); subscriptions.push(subscription::channel( location.clone(), @@ -4224,41 +4238,47 @@ impl Tab { { let output = output.clone(); tokio::task::spawn_blocking(move || { - scan_search(&path, &term, move |path, name, metadata| -> bool { - // Don't send if the result is too old - if let Some(last_modified) = *last_modified_opt.read().unwrap() { - if let Ok(modified) = metadata.modified() { - if metadata.modified().ok() < Some(last_modified) { + scan_search( + &path, + &term, + show_hidden, + move |path, name, metadata| -> bool { + // Don't send if the result is too old + if let Some(last_modified) = *last_modified_opt.read().unwrap() + { + if let Ok(modified) = metadata.modified() { + if modified < last_modified { + return true; + } + } else { return true; } - } else { - return true; } - } - match results_tx.blocking_send(( - path.to_path_buf(), - name.to_string(), - metadata, - )) { - Ok(()) => { - if !ready.swap(true, atomic::Ordering::SeqCst) { - // Wake up update method - futures::executor::block_on(async { - output - .lock() - .await - .send(Message::SearchReady(false)) - .await - }) - .is_ok() - } else { - true + match results_tx.blocking_send(( + path.to_path_buf(), + name.to_string(), + metadata, + )) { + Ok(()) => { + if !ready.swap(true, atomic::Ordering::SeqCst) { + // Wake up update method + futures::executor::block_on(async { + output + .lock() + .await + .send(Message::SearchReady(false)) + .await + }) + .is_ok() + } else { + true + } } + Err(_) => false, } - Err(_) => false, - } - }); + }, + ); log::info!( "searched for {:?} in {:?} in {:?}", term,