diff options
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 48 |
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 ); } |