Skip to content

Commit ff0a74f

Browse files
authored
refactor: deprecate ui.Padding and ui.Rect:padding() (#2574)
1 parent 9565c1b commit ff0a74f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: yazi-plugin/src/elements/pad.rs

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ impl From<ratatui::widgets::Padding> for Pad {
1717

1818
impl Pad {
1919
pub fn compose(lua: &Lua, v4: bool) -> mlua::Result<Table> {
20+
if !v4 {
21+
crate::deprecate!(
22+
lua,
23+
"The `ui.Padding` has been deprecated, please use `ui.Pad` instead, in your {}"
24+
);
25+
}
26+
2027
let new = if v4 {
2128
lua.create_function(|_, (_, top, right, bottom, left): (Table, u16, u16, u16, u16)| {
2229
Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom)))

Diff for: yazi-plugin/src/elements/rect.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ impl UserData for Rect {
7272
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
7373
methods.add_method("pad", |_, me, pad: Pad| Ok(me.pad(pad)));
7474
// TODO: deprecate this
75-
methods.add_method("padding", |_, me, pad: Pad| Ok(me.pad(pad)));
75+
methods.add_method("padding", |lua, me, pad: Pad| {
76+
crate::deprecate!(lua, "The `padding()` method of `ui.Rect` has been deprecated, please use `pad()` instead, in your {}");
77+
Ok(me.pad(pad))
78+
});
7679
methods.add_method("contains", |_, me, Rect(rect)| Ok(me.contains(rect.into())));
7780
}
7881
}

0 commit comments

Comments
 (0)