mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +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]]
|
[[package]]
|
||||||
name = "instability"
|
name = "instability"
|
||||||
version = "0.3.11"
|
version = "0.3.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "357b7205c6cd18dd2c86ed312d1e70add149aea98e7ef72b9fdf0270e555c11d"
|
checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.23.0",
|
"darling 0.23.0",
|
||||||
"indoc",
|
"indoc",
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl Actor for AcceptPayload {
|
||||||
drop(lock);
|
drop(lock);
|
||||||
|
|
||||||
let kind = kind.to_owned();
|
let kind = kind.to_owned();
|
||||||
succ!(Lives::scope(&cx.core, || {
|
succ!(Lives::scope(cx.core, || {
|
||||||
let body = payload.body.into_lua(&LUA)?;
|
let body = payload.body.into_lua(&LUA)?;
|
||||||
for (id, cb) in handlers {
|
for (id, cb) in handlers {
|
||||||
if let Err(e) = runtime_scope!(LUA, &id, cb.call::<()>(body.clone())) {
|
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 Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() };
|
||||||
let area = yazi_binding::elements::Rect::from(size);
|
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", {
|
let root = runtime_scope!(LUA, "root", {
|
||||||
LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("new", area)
|
LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("new", area)
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ impl Actor for PluginDo {
|
||||||
};
|
};
|
||||||
drop(loader);
|
drop(loader);
|
||||||
|
|
||||||
let result = Lives::scope(&cx.core, || {
|
let result = Lives::scope(cx.core, || {
|
||||||
if let Some(cb) = opt.callback {
|
if let Some(cb) = opt.callback {
|
||||||
cb(&LUA, plugin)
|
cb(&LUA, plugin)
|
||||||
} else {
|
} 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 Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() };
|
||||||
let mut layout = LAYOUT.get();
|
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())?;
|
let comps = (opt.reflow)((Position::ORIGIN, size).into())?;
|
||||||
|
|
||||||
for v in comps.sequence_values::<Value>() {
|
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 {
|
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),
|
Ok(()) => true.into_lua_multi(&lua),
|
||||||
Err(e) => (false, Error::Io(e)).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 hashbrown::{HashMap, hash_map::EntryRef};
|
||||||
use mlua::Function;
|
use mlua::Function;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Runtime {
|
pub struct Runtime {
|
||||||
frames: VecDeque<RuntimeFrame>,
|
frames: VecDeque<RuntimeFrame>,
|
||||||
blocks: HashMap<String, Vec<Function>>,
|
blocks: HashMap<String, Vec<Function>>,
|
||||||
|
|
@ -17,14 +17,8 @@ pub struct RuntimeFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Runtime {
|
impl Runtime {
|
||||||
pub fn new() -> Self { Self { frames: <_>::default(), blocks: <_>::default(), blocking: false } }
|
|
||||||
|
|
||||||
pub fn new_isolate(id: &str) -> Self {
|
pub fn new_isolate(id: &str) -> Self {
|
||||||
Self {
|
Self { frames: VecDeque::from([RuntimeFrame { id: id.to_owned() }]), ..Default::default() }
|
||||||
frames: VecDeque::from([RuntimeFrame { id: id.to_owned() }]),
|
|
||||||
blocks: <_>::default(),
|
|
||||||
blocking: false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, id: &str) { self.frames.push_back(RuntimeFrame { id: id.to_owned() }); }
|
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> {
|
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) {
|
Some(match self.blocks.entry_ref(&cur.id) {
|
||||||
EntryRef::Occupied(mut oe) => {
|
EntryRef::Occupied(mut oe) => {
|
||||||
oe.get_mut().push(f.clone());
|
oe.get_mut().push(f.clone());
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,8 @@ impl Signals {
|
||||||
CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => {
|
CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => {
|
||||||
Event::Key(key).emit()
|
Event::Key(key).emit()
|
||||||
}
|
}
|
||||||
CrosstermEvent::Mouse(mouse) => {
|
CrosstermEvent::Mouse(mouse) if YAZI.mgr.mouse_events.get().contains(mouse.kind.into()) => {
|
||||||
if YAZI.mgr.mouse_events.get().contains(mouse.kind.into()) {
|
Event::Mouse(mouse).emit()
|
||||||
Event::Mouse(mouse).emit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CrosstermEvent::Resize(..) => Event::Resize.emit(),
|
CrosstermEvent::Resize(..) => Event::Resize.emit(),
|
||||||
CrosstermEvent::FocusGained => Event::Focus.emit(),
|
CrosstermEvent::FocusGained => Event::Focus.emit(),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ pub(super) fn init_lua() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stage_1(lua: &'static Lua) -> Result<()> {
|
fn stage_1(lua: &'static Lua) -> Result<()> {
|
||||||
lua.set_app_data(Runtime::new());
|
lua.set_app_data(Runtime::default());
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl Utils {
|
||||||
if !s.is_empty() {
|
if !s.is_empty() {
|
||||||
s.push(' ');
|
s.push(' ');
|
||||||
}
|
}
|
||||||
Utils::format_one(&mut s, value)?;
|
Self::format_one(&mut s, value)?;
|
||||||
}
|
}
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl Utils {
|
||||||
async move {
|
async move {
|
||||||
loop {
|
loop {
|
||||||
let values: MultiValue = thread.resume(args)?;
|
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()
|
&& *ud == Lua::poll_pending()
|
||||||
{
|
{
|
||||||
args = lua.yield_with(values).await?;
|
args = lua.yield_with(values).await?;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,6 @@ impl Preload {
|
||||||
Priority::High => HIGH,
|
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 {
|
Ok(match value {
|
||||||
Data::String(s) => s.into_owned().into(),
|
Data::String(s) => s.into_owned().into(),
|
||||||
Data::Path(p) => p.into_strand(),
|
Data::Path(p) => p.into_strand(),
|
||||||
Data::Bytes(b) => StrandBuf::Bytes(b),
|
Data::Bytes(b) => Self::Bytes(b),
|
||||||
_ => bail!("cannot convert to StrandBuf"),
|
_ => bail!("cannot convert to StrandBuf"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ impl TryFrom<&Data> for StrandBuf {
|
||||||
Ok(match value {
|
Ok(match value {
|
||||||
Data::String(s) => s.to_string().into(),
|
Data::String(s) => s.to_string().into(),
|
||||||
Data::Path(p) => p.into_strand(),
|
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"),
|
_ => bail!("cannot convert to StrandBuf"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ impl Deref for ActionCow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ActionCow> for () {
|
impl From<ActionCow> for () {
|
||||||
fn from(_: ActionCow) -> Self { () }
|
fn from(_: ActionCow) -> Self {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Action> for ActionCow {
|
impl From<Action> for ActionCow {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use yazi_adapter::ADAPTOR;
|
||||||
|
|
||||||
pub static COLLISION: AtomicBool = AtomicBool::new(false);
|
pub static COLLISION: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Clear;
|
pub struct Clear;
|
||||||
|
|
||||||
impl Widget for 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);
|
yazi_macro::mod_flat!(error input mode op snap snaps widget);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ impl Widget for &Input {
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
crate::Clear::default().render(area, buf);
|
crate::Clear.render(area, buf);
|
||||||
|
|
||||||
Line::styled(self.display(), THEME.input.value).render(area, buf);
|
Line::styled(self.display(), THEME.input.value).render(area, buf);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue