mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: new --no-dummy option for reveal command (#2664)
This commit is contained in:
parent
a29dbb9f06
commit
bfad57d86f
3 changed files with 9 additions and 20 deletions
|
|
@ -5,7 +5,8 @@ use yazi_shared::{event::CmdCow, url::Url};
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
struct Opt {
|
struct Opt {
|
||||||
target: Url,
|
target: Url,
|
||||||
|
no_dummy: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CmdCow> for Opt {
|
impl From<CmdCow> for Opt {
|
||||||
|
|
@ -15,11 +16,11 @@ impl From<CmdCow> for Opt {
|
||||||
target = Url::from(expand_path(&target));
|
target = Url::from(expand_path(&target));
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { target }
|
Self { target, no_dummy: c.bool("no-dummy") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Url> for Opt {
|
impl From<Url> for Opt {
|
||||||
fn from(target: Url) -> Self { Self { target } }
|
fn from(target: Url) -> Self { Self { target, no_dummy: false } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
@ -32,7 +33,7 @@ impl Tab {
|
||||||
self.cd(parent.clone());
|
self.cd(parent.clone());
|
||||||
self.current.hover(child.as_urn());
|
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)]);
|
let op = FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]);
|
||||||
self.current.update_pub(self.id, op);
|
self.current.update_pub(self.id, op);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub fn compose(lua: &Lua) -> mlua::Result<Value> {
|
||||||
b"Layout" => super::Layout::compose(lua)?,
|
b"Layout" => super::Layout::compose(lua)?,
|
||||||
b"Line" => super::Line::compose(lua)?,
|
b"Line" => super::Line::compose(lua)?,
|
||||||
b"List" => super::List::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"Pos" => super::Pos::compose(lua)?,
|
||||||
b"Rect" => super::Rect::compose(lua)?,
|
b"Rect" => super::Rect::compose(lua)?,
|
||||||
b"Row" => super::Row::compose(lua)?,
|
b"Row" => super::Row::compose(lua)?,
|
||||||
|
|
|
||||||
|
|
@ -16,23 +16,11 @@ impl From<ratatui::widgets::Padding> for Pad {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pad {
|
impl Pad {
|
||||||
pub fn compose(lua: &Lua, v4: bool) -> mlua::Result<Table> {
|
pub fn compose(lua: &Lua) -> mlua::Result<Table> {
|
||||||
if !v4 {
|
let new =
|
||||||
crate::deprecate!(
|
|
||||||
lua,
|
|
||||||
"The `ui.Padding` has been deprecated, please use `ui.Pad` instead, in your {}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let new = if v4 {
|
|
||||||
lua.create_function(|_, (_, top, right, bottom, left): (Table, u16, u16, u16, u16)| {
|
lua.create_function(|_, (_, top, right, bottom, left): (Table, u16, u16, u16, u16)| {
|
||||||
Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom)))
|
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([
|
let pad = lua.create_table_from([
|
||||||
(
|
(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue