From 2e6487542ccd643d58053387114fd8d541292d93 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 11 Nov 2025 11:49:22 -0700 Subject: [PATCH] Use ignore crate to build tree view --- src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2de5809..2a7f34c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -497,16 +497,13 @@ impl App { } fn open_folder>(&mut self, path: P, mut position: u16, indent: u16) { - let read_dir = match fs::read_dir(&path) { - Ok(ok) => ok, - Err(err) => { - log::error!("failed to read directory {:?}: {}", path.as_ref(), err); - return; - } - }; - let mut nodes = Vec::new(); - for entry_res in read_dir { + for entry_res in ignore::WalkBuilder::new(&path) + .filter_entry(|entry| entry.file_name() != ".git") + .hidden(false) + .max_depth(Some(1)) + .build() + { let entry = match entry_res { Ok(ok) => ok, Err(err) => { @@ -518,7 +515,9 @@ impl App { continue; } }; - + if entry.depth() == 0 { + continue; + } let entry_path = entry.path(); let node = match ProjectNode::new(&entry_path) { Ok(ok) => ok,