From bfad57d86f66e72805c5d12ab9be0c853eccf548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 22 Apr 2025 22:22:33 +0800 Subject: [PATCH] feat: new `--no-dummy` option for `reveal` command (#2664) --- yazi-core/src/tab/commands/reveal.rs | 9 +++++---- yazi-plugin/src/elements/elements.rs | 2 +- yazi-plugin/src/elements/pad.rs | 18 +++--------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 2578e002..c7025fb4 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -5,7 +5,8 @@ use yazi_shared::{event::CmdCow, url::Url}; use crate::tab::Tab; struct Opt { - target: Url, + target: Url, + no_dummy: bool, } impl From for Opt { @@ -15,11 +16,11 @@ impl From for Opt { target = Url::from(expand_path(&target)); } - Self { target } + Self { target, no_dummy: c.bool("no-dummy") } } } impl From for Opt { - fn from(target: Url) -> Self { Self { target } } + fn from(target: Url) -> Self { Self { target, no_dummy: false } } } impl Tab { @@ -32,7 +33,7 @@ impl Tab { self.cd(parent.clone()); self.current.hover(child.as_urn()); - if self.hovered().is_none_or(|f| &child != f.urn()) { + if !opt.no_dummy && self.hovered().is_none_or(|f| &child != f.urn()) { let op = FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]); self.current.update_pub(self.id, op); } diff --git a/yazi-plugin/src/elements/elements.rs b/yazi-plugin/src/elements/elements.rs index b9f9a09f..59714e12 100644 --- a/yazi-plugin/src/elements/elements.rs +++ b/yazi-plugin/src/elements/elements.rs @@ -15,7 +15,7 @@ pub fn compose(lua: &Lua) -> mlua::Result { b"Layout" => super::Layout::compose(lua)?, b"Line" => super::Line::compose(lua)?, b"List" => super::List::compose(lua)?, - b"Pad" => super::Pad::compose(lua, true)?, + b"Pad" => super::Pad::compose(lua)?, b"Pos" => super::Pos::compose(lua)?, b"Rect" => super::Rect::compose(lua)?, b"Row" => super::Row::compose(lua)?, diff --git a/yazi-plugin/src/elements/pad.rs b/yazi-plugin/src/elements/pad.rs index 94d97e41..36ee5044 100644 --- a/yazi-plugin/src/elements/pad.rs +++ b/yazi-plugin/src/elements/pad.rs @@ -16,23 +16,11 @@ impl From for Pad { } impl Pad { - pub fn compose(lua: &Lua, v4: bool) -> mlua::Result { - if !v4 { - crate::deprecate!( - lua, - "The `ui.Padding` has been deprecated, please use `ui.Pad` instead, in your {}" - ); - } - - let new = if v4 { + pub fn compose(lua: &Lua) -> mlua::Result
{ + let new = lua.create_function(|_, (_, top, right, bottom, left): (Table, u16, u16, u16, u16)| { Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom))) - })? - } else { - lua.create_function(|_, (_, left, right, top, bottom): (Table, u16, u16, u16, u16)| { - Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom))) - })? - }; + })?; let pad = lua.create_table_from([ (