|
|
|
@ -1,8 +1,4 @@
|
|
|
|
|
use crate::app::DirectoryBuffer;
|
|
|
|
|
use crate::app::ExplorerConfig;
|
|
|
|
|
use crate::app::Node;
|
|
|
|
|
use crate::app::Task;
|
|
|
|
|
use crate::app::{InternalMsg, MsgIn};
|
|
|
|
|
use crate::app::{DirectoryBuffer, ExplorerConfig, ExternalMsg, InternalMsg, MsgIn, Node, Task};
|
|
|
|
|
use std::fs;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use std::sync::mpsc::Sender;
|
|
|
|
@ -20,9 +16,9 @@ pub fn explore(
|
|
|
|
|
let config_cloned = config.clone();
|
|
|
|
|
|
|
|
|
|
thread::spawn(move || {
|
|
|
|
|
let nodes: Vec<Node> = fs::read_dir(&path)
|
|
|
|
|
.unwrap()
|
|
|
|
|
.filter_map(|d| {
|
|
|
|
|
fs::read_dir(&path)
|
|
|
|
|
.map(|dirs| {
|
|
|
|
|
dirs.filter_map(|d| {
|
|
|
|
|
d.ok().map(|e| {
|
|
|
|
|
e.path()
|
|
|
|
|
.file_name()
|
|
|
|
@ -32,8 +28,9 @@ pub fn explore(
|
|
|
|
|
})
|
|
|
|
|
.map(|name| Node::new(parent.clone(), name))
|
|
|
|
|
.filter(|n| config.apply(n))
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
.collect::<Vec<Node>>()
|
|
|
|
|
})
|
|
|
|
|
.map(|nodes| {
|
|
|
|
|
let focus_index = if let Some(focus) = focused_path {
|
|
|
|
|
nodes
|
|
|
|
|
.iter()
|
|
|
|
@ -53,6 +50,15 @@ pub fn explore(
|
|
|
|
|
None,
|
|
|
|
|
))
|
|
|
|
|
.unwrap();
|
|
|
|
|
})
|
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
|
tx.send(Task::new(
|
|
|
|
|
1,
|
|
|
|
|
MsgIn::External(ExternalMsg::LogError(e.to_string())),
|
|
|
|
|
None,
|
|
|
|
|
))
|
|
|
|
|
.unwrap();
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if let Some(grand_parent) = path_cloned.parent() {
|
|
|
|
|