A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/edi.rs')
-rw-r--r--src/edi.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/edi.rs b/src/edi.rs
index 9a591e9..9d01fb8 100644
--- a/src/edi.rs
+++ b/src/edi.rs
@@ -183,20 +183,32 @@ macro_rules! change {
}
pub(crate) use change;
-fn rooter(
+fn rooter_(
x: &Path,
mut search: impl FnMut(OsString) -> bool + Clone,
whilst: impl for<'a> FnMut(&&'a Path) -> bool + Clone,
-) -> Option<PathBuf> {
- for f in std::fs::read_dir(&x).ok()?.filter_map(Result::ok) {
- println!("{f:?}");
+ found: &mut Vec<PathBuf>,
+) {
+ let Some(d) = std::fs::read_dir(&x).ok() else { return };
+ for f in d.filter_map(Result::ok) {
if search(f.file_name()) {
- return Some(f.path().with_file_name("").to_path_buf());
+ found.push(f.path().with_file_name("").to_path_buf());
}
}
x.parent()
.filter(whilst.clone())
- .and_then(rooter.rbind(whilst).rbind(search))
+ .map(|x| rooter_(x, search, whilst, found));
+}
+
+fn rooter(
+ x: &Path,
+ search: impl FnMut(OsString) -> bool + Clone,
+
+ whilst: impl for<'a> FnMut(&&'a Path) -> bool + Clone,
+) -> Option<PathBuf> {
+ let mut v = vec![];
+ rooter_(x, search, whilst, &mut v);
+ v.try_remove(v.len().checked_sub(1)?)
}
impl Editor {
@@ -715,6 +727,7 @@ impl Editor {
.filter_entry(|e| !is_hidden(e))
.flatten()
.filter(|x| !x.path().starts_with("."))
+ .filter(|x| !x.path().is_dir())
.map(|x| x.path().to_owned())
.collect::<Vec<_>>()
});