aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-23 07:55:42 +0000
committerBlaž Hrastnik2022-03-28 02:02:32 +0000
commit1849ad1fdee8e19622b419e3a1a3643b4fcd7f3d (patch)
tree81fed876ac878877339d257c2bb7990b29ef20ac /helix-term/src
parent92bb312f0fadc0cb60f51241a10d39783c020a3f (diff)
Clean up global search
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs48
1 files changed, 23 insertions, 25 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 01d20b28..4b4e834a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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
);
}