diff --git a/yazi-core/src/confirm/commands/show.rs b/yazi-core/src/confirm/commands/show.rs index 84534244..a2d71cd1 100644 --- a/yazi-core/src/confirm/commands/show.rs +++ b/yazi-core/src/confirm/commands/show.rs @@ -20,7 +20,7 @@ impl TryFrom for Opt { impl Confirm { pub fn show(&mut self, opt: impl TryInto) { - let Ok(opt) = opt.try_into() else { + let Ok(opt): Result = opt.try_into() else { return; }; diff --git a/yazi-fm/src/confirm/confirm.rs b/yazi-fm/src/confirm/confirm.rs index 7ea09bc5..895d97ee 100644 --- a/yazi-fm/src/confirm/confirm.rs +++ b/yazi-fm/src/confirm/confirm.rs @@ -25,9 +25,8 @@ impl Widget for Confirm<'_> { .title_alignment(Alignment::Center) .render(area, buf); - let content = confirm.content.clone(); let content_border = confirm.list.line_count(area.width) != 0; - let content_height = content.line_count(area.width) as u16; + let content_height = confirm.content.line_count(area.width) as u16; let chunks = Layout::vertical([ Constraint::Length(if content_height == 0 { diff --git a/yazi-plugin/src/composer.rs b/yazi-plugin/src/composer.rs index 4f65d2e0..70c76f1b 100644 --- a/yazi-plugin/src/composer.rs +++ b/yazi-plugin/src/composer.rs @@ -3,7 +3,7 @@ use mlua::{IntoLua, Lua, MetaMethod, Table, Value}; pub struct Composer; impl Composer { - pub fn make(lua: &Lua, cap: usize, f: F) -> mlua::Result + pub fn make(lua: &Lua, f: F) -> mlua::Result where F: Fn(&Lua, &[u8]) -> mlua::Result + 'static, { @@ -13,7 +13,7 @@ impl Composer { Ok(v) })?; - let tbl = lua.create_table_with_capacity(0, cap)?; + let tbl = lua.create_table()?; tbl.set_metatable(Some(lua.create_table_from([(MetaMethod::Index.name(), index)])?)); tbl.into_lua(lua) } diff --git a/yazi-plugin/src/config/plugin.rs b/yazi-plugin/src/config/plugin.rs index d68901eb..6e9d3430 100644 --- a/yazi-plugin/src/config/plugin.rs +++ b/yazi-plugin/src/config/plugin.rs @@ -8,7 +8,7 @@ pub(super) struct Plugin; impl Plugin { pub(super) fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 5, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"fetchers" => Plugin::fetchers(lua)?, b"spotter" => Plugin::spotter(lua)?, diff --git a/yazi-plugin/src/config/runtime.rs b/yazi-plugin/src/config/runtime.rs index d1335f3b..18e5618e 100644 --- a/yazi-plugin/src/config/runtime.rs +++ b/yazi-plugin/src/config/runtime.rs @@ -12,7 +12,7 @@ pub struct Runtime; impl Runtime { pub fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 10, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"args" => Self::args(lua)?, b"term" => super::Term::compose(lua)?, @@ -27,7 +27,7 @@ impl Runtime { } fn args(lua: &Lua) -> mlua::Result { - Composer::make(lua, 5, |lua, key| match key { + Composer::make(lua, |lua, key| match key { b"entries" => lua.create_sequence_from(ARGS.entries.iter().map(Url::new))?.into_lua(lua), b"cwd_file" => ARGS.cwd_file.as_ref().map(Url::new).into_lua(lua), b"chooser_file" => ARGS.chooser_file.as_ref().map(Url::new).into_lua(lua), @@ -36,7 +36,7 @@ impl Runtime { } fn mgr(lua: &Lua) -> mlua::Result { - Composer::make(lua, 15, |lua, key| { + Composer::make(lua, |lua, key| { let m = &YAZI.mgr; match key { b"ratio" => lua.to_value_with(&m.ratio, OPTS)?, @@ -60,7 +60,7 @@ impl Runtime { } fn preview(lua: &Lua) -> mlua::Result { - Composer::make(lua, 15, |lua, key| { + Composer::make(lua, |lua, key| { let p = &YAZI.preview; match key { b"wrap" => lua.to_value_with(&p.wrap, OPTS)?, @@ -83,7 +83,7 @@ impl Runtime { } fn tasks(lua: &Lua) -> mlua::Result { - Composer::make(lua, 10, |lua, key| { + Composer::make(lua, |lua, key| { let t = &YAZI.tasks; match key { b"micro_workers" => lua.to_value_with(&t.micro_workers, OPTS)?, diff --git a/yazi-plugin/src/config/term.rs b/yazi-plugin/src/config/term.rs index 2fd20fe9..510339c5 100644 --- a/yazi-plugin/src/config/term.rs +++ b/yazi-plugin/src/config/term.rs @@ -7,7 +7,7 @@ pub(super) struct Term; impl Term { pub(super) fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 5, |lua, key| match key { + Composer::make(lua, |lua, key| match key { b"light" => EMULATOR.get().light.into_lua(lua), b"cell_size" => Self::cell_size(lua)?.into_lua(lua), _ => Ok(Value::Nil), diff --git a/yazi-plugin/src/config/theme.rs b/yazi-plugin/src/config/theme.rs index e144a7d7..2ff5f2b6 100644 --- a/yazi-plugin/src/config/theme.rs +++ b/yazi-plugin/src/config/theme.rs @@ -8,7 +8,7 @@ pub struct Theme; impl Theme { pub fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 15, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"mgr" => lua.to_value_with(&THEME.mgr, OPTS)?, b"tabs" => lua.to_value_with(&THEME.tabs, OPTS)?, diff --git a/yazi-plugin/src/elements/elements.rs b/yazi-plugin/src/elements/elements.rs index 75b01c89..853172d8 100644 --- a/yazi-plugin/src/elements/elements.rs +++ b/yazi-plugin/src/elements/elements.rs @@ -5,7 +5,7 @@ use super::Renderable; use crate::Composer; pub fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 20, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"Align" => super::Align::compose(lua)?, b"Bar" => super::Bar::compose(lua)?, diff --git a/yazi-plugin/src/fs/fs.rs b/yazi-plugin/src/fs/fs.rs index 18d610cd..95c86e0f 100644 --- a/yazi-plugin/src/fs/fs.rs +++ b/yazi-plugin/src/fs/fs.rs @@ -7,7 +7,7 @@ use yazi_fs::{mounts::PARTITIONS, remove_dir_clean}; use crate::{Composer, bindings::{Cha, SizeCalculator}, file::File}; pub fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 10, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"op" => op(lua)?, b"cwd" => cwd(lua)?, diff --git a/yazi-plugin/src/pubsub/mod.rs b/yazi-plugin/src/pubsub/mod.rs index ca352f71..c984157f 100644 --- a/yazi-plugin/src/pubsub/mod.rs +++ b/yazi-plugin/src/pubsub/mod.rs @@ -7,7 +7,7 @@ use crate::Composer; yazi_macro::mod_flat!(pubsub); pub(super) fn compose(lua: &Lua) -> mlua::Result { - Composer::make(lua, 10, |lua, key| { + Composer::make(lua, |lua, key| { match key { b"pub" => Pubsub::r#pub(lua)?, b"pub_to" => Pubsub::pub_to(lua)?, diff --git a/yazi-plugin/src/utils/utils.rs b/yazi-plugin/src/utils/utils.rs index e9b99bc1..7aa988a5 100644 --- a/yazi-plugin/src/utils/utils.rs +++ b/yazi-plugin/src/utils/utils.rs @@ -5,7 +5,7 @@ use crate::Composer; pub(super) struct Utils; pub fn compose(lua: &Lua, isolate: bool) -> mlua::Result { - Composer::make(lua, 45, move |lua, key| { + Composer::make(lua, move |lua, key| { match key { // App b"id" => Utils::id(lua)?,