Clean up global search

pull/1872/head
Blaž Hrastnik 3 years ago
parent 92bb312f0f
commit 1849ad1fde
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -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
);
}

Loading…
Cancel
Save