|
|
|
@ -1712,39 +1712,37 @@ fn global_search(cx: &mut Context) {
|
|
|
|
|
.max_depth(file_picker_config.max_depth)
|
|
|
|
|
.build_parallel()
|
|
|
|
|
.run(|| {
|
|
|
|
|
let mut searcher_cl = searcher.clone();
|
|
|
|
|
let matcher_cl = matcher.clone();
|
|
|
|
|
let all_matches_sx_cl = all_matches_sx.clone();
|
|
|
|
|
Box::new(move |dent: Result<DirEntry, ignore::Error>| -> WalkState {
|
|
|
|
|
let dent = match dent {
|
|
|
|
|
Ok(dent) => dent,
|
|
|
|
|
let mut searcher = searcher.clone();
|
|
|
|
|
let matcher = matcher.clone();
|
|
|
|
|
let all_matches_sx = all_matches_sx.clone();
|
|
|
|
|
Box::new(move |entry: Result<DirEntry, ignore::Error>| -> WalkState {
|
|
|
|
|
let entry = match entry {
|
|
|
|
|
Ok(entry) => entry,
|
|
|
|
|
Err(_) => return WalkState::Continue,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
match dent.file_type() {
|
|
|
|
|
Some(fi) => {
|
|
|
|
|
if !fi.is_file() {
|
|
|
|
|
return WalkState::Continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
None => return WalkState::Continue,
|
|
|
|
|
}
|
|
|
|
|
match entry.file_type() {
|
|
|
|
|
Some(entry) if entry.is_file() => {}
|
|
|
|
|
// skip everything else
|
|
|
|
|
_ => return WalkState::Continue,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let result_sink = sinks::UTF8(|line_num, _| {
|
|
|
|
|
match all_matches_sx_cl
|
|
|
|
|
.send((line_num as usize - 1, dent.path().to_path_buf()))
|
|
|
|
|
{
|
|
|
|
|
Ok(_) => Ok(true),
|
|
|
|
|
Err(_) => Ok(false),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
let result =
|
|
|
|
|
searcher_cl.search_path(&matcher_cl, dent.path(), result_sink);
|
|
|
|
|
let result = searcher.search_path(
|
|
|
|
|
&matcher,
|
|
|
|
|
entry.path(),
|
|
|
|
|
sinks::UTF8(|line_num, _| {
|
|
|
|
|
all_matches_sx
|
|
|
|
|
.send((line_num as usize - 1, entry.path().to_path_buf()))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
Ok(true)
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if let Err(err) = result {
|
|
|
|
|
log::error!(
|
|
|
|
|
"Global search error: {}, {}",
|
|
|
|
|
dent.path().display(),
|
|
|
|
|
entry.path().display(),
|
|
|
|
|
err
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|