on master help sign in
Clean up global search
commit1849ad1fdee8e19622b419e3a1a3643b4fcd7f3d authorBlaž Hrastnik <blaz@mxxn.io> dateWed 23 Mar 2022, 16:55 (5 years ago) parent92bb312
1 file changed+23−25
helix-term/src/commands.rs+23−25
helix-term/src/commands.rs+23−25
@@ -1712,39 +1712,37 @@ fn global_search(cx: &mut Context) {
17121712 .max_depth(file_picker_config.max_depth)
17131713 .build_parallel()
17141714 .run(|| {
1715− let mut searcher_cl = searcher.clone();
1716− let matcher_cl = matcher.clone();
1717− let all_matches_sx_cl = all_matches_sx.clone();
1718− Box::new(move |dent: Result<DirEntry, ignore::Error>| -> WalkState {
1719− let dent = match dent {
1720− Ok(dent) => dent,
1715+ let mut searcher = searcher.clone();
1716+ let matcher = matcher.clone();
1717+ let all_matches_sx = all_matches_sx.clone();
1718+ Box::new(move |entry: Result<DirEntry, ignore::Error>| -> WalkState {
1719+ let entry = match entry {
1720+ Ok(entry) => entry,
17211721 Err(_) => return WalkState::Continue,
17221722 };
17231723
1724− match dent.file_type() {
1725− Some(fi) => {
1726− if !fi.is_file() {
1727− return WalkState::Continue;
1728− }
1729− }
1730− None => return WalkState::Continue,
1731− }
1724+ match entry.file_type() {
1725+ Some(entry) if entry.is_file() => {}
1726+ // skip everything else
1727+ _ => return WalkState::Continue,
1728+ };
17321729
1733− let result_sink = sinks::UTF8(|line_num, _| {
1734− match all_matches_sx_cl
1735− .send((line_num as usize - 1, dent.path().to_path_buf()))
1736− {
1737− Ok(_) => Ok(true),
1738− Err(_) => Ok(false),
1739− }
1740− });
1741− let result =
1742− searcher_cl.search_path(&matcher_cl, dent.path(), result_sink);
1730+ let result = searcher.search_path(
1731+ &matcher,
1732+ entry.path(),
1733+ sinks::UTF8(|line_num, _| {
1734+ all_matches_sx
1735+ .send((line_num as usize - 1, entry.path().to_path_buf()))
1736+ .unwrap();
1737+
1738+ Ok(true)
1739+ }),
1740+ );
17431741
17441742 if let Err(err) = result {
17451743 log::error!(
17461744 "Global search error: {}, {}",
1747− dent.path().display(),
1745+ entry.path().display(),
17481746 err
17491747 );
17501748 }