diff --git a/Cargo.lock b/Cargo.lock index cb74512d..54133854 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -346,9 +346,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.22" +version = "1.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" +checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" dependencies = [ "jobserver", "libc", diff --git a/yazi-core/src/cmp/commands/trigger.rs b/yazi-core/src/cmp/commands/trigger.rs index d207c7f5..713d6735 100644 --- a/yazi-core/src/cmp/commands/trigger.rs +++ b/yazi-core/src/cmp/commands/trigger.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, mem, path::{MAIN_SEPARATOR_STR, PathBuf}}; +use std::{borrow::Cow, ffi::OsString, mem, path::{MAIN_SEPARATOR_STR, Path, PathBuf}}; use tokio::fs; use yazi_fs::{CWD, expand_path}; @@ -44,6 +44,13 @@ impl Cmp { tokio::spawn(async move { let mut dir = fs::read_dir(&parent).await?; let mut cache = vec![]; + + // "/" is both a directory separator and the root directory per se + // As there's no parent directory for the FS root, it is a special case + if parent == Path::new("/") { + cache.push(CmpItem { name: OsString::new(), is_dir: true }); + } + while let Ok(Some(ent)) = dir.next_entry().await { if let Ok(ft) = ent.file_type().await { cache.push(CmpItem { name: ent.file_name(), is_dir: ft.is_dir() });