perf: reduce file change event frequency (#2820)

This commit is contained in:
三咲雅 misaki masa 2025-06-01 09:20:17 +08:00 committed by GitHub
parent b65a88075a
commit d5038eeed5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 2 additions and 44 deletions

View file

@ -122,7 +122,7 @@ impl Watcher {
async fn fan_out(rx: UnboundedReceiver<Url>) {
// TODO: revert this once a new notification is implemented
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(100));
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(350));
pin!(rx);
while let Some(chunk) = rx.next().await {

View file

@ -1,6 +1,6 @@
local M = {}
function M:peek() end
function M:peek(job) ya.preview_widget(job, {}) end
function M:seek() end

View file

@ -152,21 +152,6 @@ impl UserData for Command {
}
Ok(ud)
});
// TODO: remove this
methods.add_function_mut("args", |lua, (ud, args): (AnyUserData, Vec<mlua::String>)| {
crate::deprecate!(
lua,
"The `args()` method on `Command` is deprecated, use `arg()` instead in your {}\n\nSee #2752 for more details: https://github.com/sxyazi/yazi/pull/2752"
);
{
let mut me = ud.borrow_mut::<Self>()?;
for arg in args {
me.inner.arg(arg.to_string_lossy());
}
}
Ok(ud)
});
methods.add_function_mut("cwd", |_, (ud, dir): (AnyUserData, mlua::String)| {
ud.borrow_mut::<Self>()?.inner.current_dir(dir.to_str()?.as_ref());
Ok(ud)

View file

@ -21,34 +21,10 @@ impl Utils {
})
}
// TODO: remove
pub(super) fn app_emit(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, (name, args): (String, Table)| {
crate::deprecate!(
lua,
"`ya.app_emit()` is deprecated, use `ya.emit()` instead, in your {}\n\nSee #2653 for more details: https://github.com/sxyazi/yazi/pull/2653"
);
emit!(Call(Cmd { name, args: Sendable::table_to_args(args)?, layer: Layer::App }));
Ok(())
})
}
pub(super) fn mgr_emit(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|_, (name, args): (String, Table)| {
emit!(Call(Cmd { name, args: Sendable::table_to_args(args)?, layer: Layer::Mgr }));
Ok(())
})
}
// TODO: remove
pub(super) fn input_emit(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, (name, args): (String, Table)| {
crate::deprecate!(
lua,
"`ya.input_emit()` is deprecated, use `ya.emit()` instead, in your {}\n\nSee #2653 for more details: https://github.com/sxyazi/yazi/pull/2653"
);
emit!(Call(Cmd { name, args: Sendable::table_to_args(args)?, layer: Layer::Input }));
Ok(())
})
}
}

View file

@ -17,10 +17,8 @@ pub fn compose(lua: &Lua, isolate: bool) -> mlua::Result<Value> {
// Call
b"render" => Utils::render(lua)?,
b"emit" => Utils::emit(lua)?,
b"app_emit" => Utils::app_emit(lua)?,
b"mgr_emit" => Utils::mgr_emit(lua)?,
b"manager_emit" => Utils::mgr_emit(lua)?, // TODO: remove this in the future
b"input_emit" => Utils::input_emit(lua)?,
// Image
b"image_info" => Utils::image_info(lua)?,
@ -44,7 +42,6 @@ pub fn compose(lua: &Lua, isolate: bool) -> mlua::Result<Value> {
// Preview
b"preview_code" => Utils::preview_code(lua)?,
b"preview_widget" => Utils::preview_widget(lua)?,
b"preview_widgets" => Utils::preview_widget(lua)?, // TODO: remove this in the future
// Process
b"proc_info" => Utils::proc_info(lua)?,