feat: new --no-dummy option for reveal command (#2664)

This commit is contained in:
三咲雅 · Misaki Masa 2025-04-22 22:22:33 +08:00 committed by GitHub
parent a29dbb9f06
commit bfad57d86f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 20 deletions

View file

@ -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<CmdCow> for Opt {
@ -15,11 +16,11 @@ impl From<CmdCow> for Opt {
target = Url::from(expand_path(&target));
}
Self { target }
Self { target, no_dummy: c.bool("no-dummy") }
}
}
impl From<Url> 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);
}

View file

@ -15,7 +15,7 @@ pub fn compose(lua: &Lua) -> mlua::Result<Value> {
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)?,

View file

@ -16,23 +16,11 @@ impl From<ratatui::widgets::Padding> for Pad {
}
impl Pad {
pub fn compose(lua: &Lua, v4: bool) -> mlua::Result<Table> {
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<Table> {
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([
(