mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
refactor: make Clippy happy
This commit is contained in:
parent
de01a56ac5
commit
da96795303
37 changed files with 23 additions and 31 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -2036,9 +2036,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.11"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "357b7205c6cd18dd2c86ed312d1e70add149aea98e7ef72b9fdf0270e555c11d"
|
||||
checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971"
|
||||
dependencies = [
|
||||
"darling 0.23.0",
|
||||
"indoc",
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ impl Actor for AcceptPayload {
|
|||
drop(lock);
|
||||
|
||||
let kind = kind.to_owned();
|
||||
succ!(Lives::scope(&cx.core, || {
|
||||
succ!(Lives::scope(cx.core, || {
|
||||
let body = payload.body.into_lua(&LUA)?;
|
||||
for (id, cb) in handlers {
|
||||
if let Err(e) = runtime_scope!(LUA, &id, cb.call::<()>(body.clone())) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl Actor for Mouse {
|
|||
let Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() };
|
||||
let area = yazi_binding::elements::Rect::from(size);
|
||||
|
||||
let result = Lives::scope(&cx.core, move || {
|
||||
let result = Lives::scope(cx.core, move || {
|
||||
let root = runtime_scope!(LUA, "root", {
|
||||
LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("new", area)
|
||||
})?;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ impl Actor for PluginDo {
|
|||
};
|
||||
drop(loader);
|
||||
|
||||
let result = Lives::scope(&cx.core, || {
|
||||
let result = Lives::scope(cx.core, || {
|
||||
if let Some(cb) = opt.callback {
|
||||
cb(&LUA, plugin)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ impl Actor for Reflow {
|
|||
let Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() };
|
||||
let mut layout = LAYOUT.get();
|
||||
|
||||
let result = Lives::scope(&cx.core, || {
|
||||
let result = Lives::scope(cx.core, || {
|
||||
let comps = (opt.reflow)((Position::ORIGIN, size).into())?;
|
||||
|
||||
for v in comps.sequence_values::<Value>() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl UserData for Fd {
|
|||
}
|
||||
});
|
||||
methods.add_async_method_mut("write_all", |lua, mut me, src: mlua::String| async move {
|
||||
match me.0.write_all(&*src.as_bytes()).await {
|
||||
match me.0.write_all(&src.as_bytes()).await {
|
||||
Ok(()) => true.into_lua_multi(&lua),
|
||||
Err(e) => (false, Error::Io(e)).into_lua_multi(&lua),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use anyhow::{Context, Result};
|
|||
use hashbrown::{HashMap, hash_map::EntryRef};
|
||||
use mlua::Function;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Runtime {
|
||||
frames: VecDeque<RuntimeFrame>,
|
||||
blocks: HashMap<String, Vec<Function>>,
|
||||
|
|
@ -17,14 +17,8 @@ pub struct RuntimeFrame {
|
|||
}
|
||||
|
||||
impl Runtime {
|
||||
pub fn new() -> Self { Self { frames: <_>::default(), blocks: <_>::default(), blocking: false } }
|
||||
|
||||
pub fn new_isolate(id: &str) -> Self {
|
||||
Self {
|
||||
frames: VecDeque::from([RuntimeFrame { id: id.to_owned() }]),
|
||||
blocks: <_>::default(),
|
||||
blocking: false,
|
||||
}
|
||||
Self { frames: VecDeque::from([RuntimeFrame { id: id.to_owned() }]), ..Default::default() }
|
||||
}
|
||||
|
||||
pub fn push(&mut self, id: &str) { self.frames.push_back(RuntimeFrame { id: id.to_owned() }); }
|
||||
|
|
@ -54,7 +48,7 @@ impl Runtime {
|
|||
}
|
||||
|
||||
pub fn put_block(&mut self, f: &Function) -> Option<usize> {
|
||||
let Some(cur) = self.frames.back().filter(|f| f.id != "init") else { return None };
|
||||
let cur = self.frames.back().filter(|f| f.id != "init")?;
|
||||
Some(match self.blocks.entry_ref(&cur.id) {
|
||||
EntryRef::Occupied(mut oe) => {
|
||||
oe.get_mut().push(f.clone());
|
||||
|
|
|
|||
|
|
@ -54,10 +54,8 @@ impl Signals {
|
|||
CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => {
|
||||
Event::Key(key).emit()
|
||||
}
|
||||
CrosstermEvent::Mouse(mouse) => {
|
||||
if YAZI.mgr.mouse_events.get().contains(mouse.kind.into()) {
|
||||
Event::Mouse(mouse).emit();
|
||||
}
|
||||
CrosstermEvent::Mouse(mouse) if YAZI.mgr.mouse_events.get().contains(mouse.kind.into()) => {
|
||||
Event::Mouse(mouse).emit()
|
||||
}
|
||||
CrosstermEvent::Resize(..) => Event::Resize.emit(),
|
||||
CrosstermEvent::FocusGained => Event::Focus.emit(),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub(super) fn init_lua() -> Result<()> {
|
|||
}
|
||||
|
||||
fn stage_1(lua: &'static Lua) -> Result<()> {
|
||||
lua.set_app_data(Runtime::new());
|
||||
lua.set_app_data(Runtime::default());
|
||||
|
||||
// Base
|
||||
let globals = lua.globals();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl Utils {
|
|||
if !s.is_empty() {
|
||||
s.push(' ');
|
||||
}
|
||||
Utils::format_one(&mut s, value)?;
|
||||
Self::format_one(&mut s, value)?;
|
||||
}
|
||||
Ok(s)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl Utils {
|
|||
async move {
|
||||
loop {
|
||||
let values: MultiValue = thread.resume(args)?;
|
||||
if let Some(Value::LightUserData(ud)) = values.get(0)
|
||||
if let Some(Value::LightUserData(ud)) = values.front()
|
||||
&& *ud == Lua::poll_pending()
|
||||
{
|
||||
args = lua.yield_with(values).await?;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ impl Preload {
|
|||
Priority::High => HIGH,
|
||||
};
|
||||
|
||||
_ = self.tx.try_send(r#in.into(), priority);
|
||||
_ = self.tx.try_send(r#in, priority);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ impl TryFrom<Data> for StrandBuf {
|
|||
Ok(match value {
|
||||
Data::String(s) => s.into_owned().into(),
|
||||
Data::Path(p) => p.into_strand(),
|
||||
Data::Bytes(b) => StrandBuf::Bytes(b),
|
||||
Data::Bytes(b) => Self::Bytes(b),
|
||||
_ => bail!("cannot convert to StrandBuf"),
|
||||
})
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ impl TryFrom<&Data> for StrandBuf {
|
|||
Ok(match value {
|
||||
Data::String(s) => s.to_string().into(),
|
||||
Data::Path(p) => p.into_strand(),
|
||||
Data::Bytes(b) => StrandBuf::Bytes(b.clone()),
|
||||
Data::Bytes(b) => Self::Bytes(b.clone()),
|
||||
_ => bail!("cannot convert to StrandBuf"),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl Deref for ActionCow {
|
|||
}
|
||||
|
||||
impl From<ActionCow> for () {
|
||||
fn from(_: ActionCow) -> Self { () }
|
||||
fn from(_: ActionCow) -> Self {}
|
||||
}
|
||||
|
||||
impl From<Action> for ActionCow {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use yazi_adapter::ADAPTOR;
|
|||
|
||||
pub static COLLISION: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Clear;
|
||||
|
||||
impl Widget for Clear {
|
||||
|
|
|
|||
1
yazi-widgets/src/input/actor/mod.rs
Normal file
1
yazi-widgets/src/input/actor/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
yazi_macro::mod_flat!(actor backspace backward casefy complete delete escape forward insert kill paste r#move r#type redo replace undo visual yank);
|
||||
|
|
@ -1 +0,0 @@
|
|||
yazi_macro::mod_flat!(backspace backward casefy commands complete delete escape forward insert kill paste r#move r#type redo replace undo visual yank);
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
yazi_macro::mod_pub!(commands parser);
|
||||
yazi_macro::mod_pub!(actor parser);
|
||||
|
||||
yazi_macro::mod_flat!(error input mode op snap snaps widget);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ impl Widget for &Input {
|
|||
where
|
||||
Self: Sized,
|
||||
{
|
||||
crate::Clear::default().render(area, buf);
|
||||
crate::Clear.render(area, buf);
|
||||
|
||||
Line::styled(self.display(), THEME.input.value).render(area, buf);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue