This commit is contained in:
sxyazi 2024-05-01 20:37:19 +08:00
parent c606e7f08c
commit 7edf721daf
No known key found for this signature in database
4 changed files with 7 additions and 11 deletions

1
Cargo.lock generated
View file

@ -2762,7 +2762,6 @@ name = "yazi-core"
version = "0.2.5"
dependencies = [
"anyhow",
"base64 0.22.0",
"bitflags 2.5.0",
"crossterm",
"futures",

View file

@ -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"

View file

@ -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);
}

View file

@ -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<String>| 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()
}
})?,
)?;