From ab04ce5d77365e60987433068a59eb68f27f29ef Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 25 Nov 2024 23:29:31 +0800 Subject: [PATCH] fix: make `cd` expand variables regardless --- yazi-core/src/tab/commands/cd.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index 69799cc2e..69b59e29f 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -17,16 +17,20 @@ struct Opt { impl From for Opt { fn from(mut c: Cmd) -> Self { - let mut target = c.take_first().and_then(Data::into_url).unwrap_or_default(); - if target.is_regular() { - target = Url::from(expand_path(&target)); + Self { + interactive: c.bool("interactive"), + ..Self::from(c.take_first().and_then(Data::into_url).unwrap_or_default()) } - - Self { target, interactive: c.bool("interactive") } } } + impl From for Opt { - fn from(target: Url) -> Self { Self { target, interactive: false } } + fn from(mut target: Url) -> Self { + if target.is_regular() { + target = Url::from(expand_path(&target)); + } + Self { target, interactive: false } + } } impl Tab {