diff --git a/Cargo.lock b/Cargo.lock index 5a6d67f0..fe2d1f46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2762,7 +2762,6 @@ name = "yazi-core" version = "0.2.5" dependencies = [ "anyhow", - "base64 0.22.0", "bitflags 2.5.0", "crossterm", "futures", diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index ed3f7ff0..edddfec7 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -20,7 +20,6 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies anyhow = "1.0.82" -base64 = "0.22.0" bitflags = "2.5.0" crossterm = "0.27.0" futures = "0.3.30" diff --git a/yazi-plugin/src/lib.rs b/yazi-plugin/src/lib.rs index 0d0bc923..cc74d28c 100644 --- a/yazi-plugin/src/lib.rs +++ b/yazi-plugin/src/lib.rs @@ -2,7 +2,7 @@ pub mod bindings; mod cast; -pub mod clipboard; +mod clipboard; mod config; pub mod elements; pub mod external; @@ -25,7 +25,8 @@ pub use opt::*; pub use runtime::*; pub fn init() { + CLIPBOARD.with(Default::default); + crate::loader::init(); crate::init_lua(); - CLIPBOARD.with(Default::default); } diff --git a/yazi-plugin/src/utils/text.rs b/yazi-plugin/src/utils/text.rs index 0c1c4cdf..a1045261 100644 --- a/yazi-plugin/src/utils/text.rs +++ b/yazi-plugin/src/utils/text.rs @@ -34,15 +34,12 @@ impl Utils { ya.raw_set( "clipboard", - lua.create_async_function(|lua, text: mlua::String| async move { - let text = text.to_string_lossy().into_owned(); - - if text.is_empty() { - let clipboard_data = CLIPBOARD.get().await; - Some(lua.create_string(clipboard_data.as_encoded_bytes())).transpose() - } else { + lua.create_async_function(|lua, text: Option| async move { + if let Some(text) = text { CLIPBOARD.set(text).await; Ok(None) + } else { + Some(lua.create_string(CLIPBOARD.get().await.as_encoded_bytes())).transpose() } })?, )?;