Use ignore crate to build tree view
This commit is contained in:
parent
b48e7b0865
commit
2e6487542c
1 changed files with 9 additions and 10 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -497,16 +497,13 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_folder<P: AsRef<Path>>(&mut self, path: P, mut position: u16, indent: u16) {
|
fn open_folder<P: AsRef<Path>>(&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();
|
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 {
|
let entry = match entry_res {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
@ -518,7 +515,9 @@ impl App {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if entry.depth() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let entry_path = entry.path();
|
let entry_path = entry.path();
|
||||||
let node = match ProjectNode::new(&entry_path) {
|
let node = match ProjectNode::new(&entry_path) {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue