From 0f56ba88f378059f42793d899d7b354ec3a1cdc2 Mon Sep 17 00:00:00 2001 From: Eugene Diachkin Date: Mon, 19 May 2025 12:33:18 +0300 Subject: [PATCH] Add the / directory to suggestions in `cd --interactive` To be able to jump directly to `/` via `g SPACE` --- yazi-core/src/cmp/commands/trigger.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/yazi-core/src/cmp/commands/trigger.rs b/yazi-core/src/cmp/commands/trigger.rs index d207c7f5..ca282dd6 100644 --- a/yazi-core/src/cmp/commands/trigger.rs +++ b/yazi-core/src/cmp/commands/trigger.rs @@ -50,6 +50,12 @@ impl Cmp { } } + // "/" 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.as_path() == std::path::Path::new("/") { + cache.push(CmpItem { name: "".into(), is_dir: true }); + } + if !cache.is_empty() { cache.sort_unstable_by(|a, b| { natsort(a.name.as_encoded_bytes(), b.name.as_encoded_bytes(), false)