Switch to Lua 5.4

This commit is contained in:
sxyazi 2023-12-28 02:56:18 +08:00
parent f0535ef824
commit a005f20a9c
No known key found for this signature in database
3 changed files with 9 additions and 20 deletions

View file

@ -23,6 +23,7 @@ better-panic = "^0"
crossterm = { version = "^0", features = [ "event-stream" ] } crossterm = { version = "^0", features = [ "event-stream" ] }
fdlimit = "^0" fdlimit = "^0"
futures = "^0" futures = "^0"
mlua = { version = "^0", features = [ "lua54", "vendored" ] }
ratatui = "^0" ratatui = "^0"
tokio = { version = "^1", features = [ "parking_lot" ] } tokio = { version = "^1", features = [ "parking_lot" ] }
unicode-width = "^0" unicode-width = "^0"
@ -36,12 +37,6 @@ tracing-subscriber = "^0"
libc = "^0" libc = "^0"
signal-hook-tokio = { version = "^0", features = [ "futures-v0_3" ] } signal-hook-tokio = { version = "^0", features = [ "futures-v0_3" ] }
[target.'cfg(any(target_arch="riscv64", target_arch="loongarch64"))'.dependencies]
mlua = { version = "^0", features = [ "lua52", "vendored" ] }
[target.'cfg(not(any(target_arch="riscv64", target_arch="loongarch64")))'.dependencies]
mlua = { version = "^0", features = [ "luajit52", "vendored" ] }
[[bin]] [[bin]]
name = "yazi" name = "yazi"
path = "src/main.rs" path = "src/main.rs"

View file

@ -20,6 +20,7 @@ crossterm = "^0"
futures = "^0" futures = "^0"
libc = "^0" libc = "^0"
md-5 = "^0" md-5 = "^0"
mlua = { version = "^0", features = [ "lua54", "vendored", "serialize", "macros", "async" ] }
parking_lot = "^0" parking_lot = "^0"
ratatui = "^0" ratatui = "^0"
serde = "^1" serde = "^1"
@ -30,9 +31,3 @@ tokio-util = "^0"
tracing = { version = "^0", features = [ "max_level_debug", "release_max_level_warn" ] } tracing = { version = "^0", features = [ "max_level_debug", "release_max_level_warn" ] }
unicode-width = "^0" unicode-width = "^0"
yazi-prebuild = "^0" yazi-prebuild = "^0"
[target.'cfg(any(target_arch="riscv64", target_arch="loongarch64"))'.dependencies]
mlua = { version = "^0", features = [ "lua52", "vendored", "serialize", "macros", "async" ] }
[target.'cfg(not(any(target_arch="riscv64", target_arch="loongarch64")))'.dependencies]
mlua = { version = "^0", features = [ "luajit52", "vendored", "serialize", "macros", "async" ] }

View file

@ -12,19 +12,18 @@ pub fn peek(exec: &Exec, file: yazi_shared::fs::File, skip: usize) -> Cancellati
let ct = CancellationToken::new(); let ct = CancellationToken::new();
let cmd = exec.cmd.to_owned(); let cmd = exec.cmd.to_owned();
let ct2 = ct.clone(); let (ct1, ct2) = (ct.clone(), ct.clone());
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
let future = async { let future = async {
LOADED.ensure(&cmd).await.into_lua_err()?; LOADED.ensure(&cmd).await.into_lua_err()?;
let lua = slim_lua()?; let lua = slim_lua()?;
// FIXME: this will cause a panic lua.set_hook(
// lua.set_hook( HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000),
// HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000), move |_, _| {
// move |_, _| { if ct1.is_cancelled() { Err("cancelled".into_lua_err()) } else { Ok(()) }
// if ct1.is_cancelled() { Err("cancelled".into_lua_err()) } else { Ok(()) } },
// }, );
// );
let plugin: Table = if let Some(b) = LOADED.read().get(&cmd) { let plugin: Table = if let Some(b) = LOADED.read().get(&cmd) {
lua.load(b).call(())? lua.load(b).call(())?