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" version = "0.2.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.0",
"bitflags 2.5.0", "bitflags 2.5.0",
"crossterm", "crossterm",
"futures", "futures",

View file

@ -20,7 +20,6 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" }
# External dependencies # External dependencies
anyhow = "1.0.82" anyhow = "1.0.82"
base64 = "0.22.0"
bitflags = "2.5.0" bitflags = "2.5.0"
crossterm = "0.27.0" crossterm = "0.27.0"
futures = "0.3.30" futures = "0.3.30"

View file

@ -2,7 +2,7 @@
pub mod bindings; pub mod bindings;
mod cast; mod cast;
pub mod clipboard; mod clipboard;
mod config; mod config;
pub mod elements; pub mod elements;
pub mod external; pub mod external;
@ -25,7 +25,8 @@ pub use opt::*;
pub use runtime::*; pub use runtime::*;
pub fn init() { pub fn init() {
CLIPBOARD.with(Default::default);
crate::loader::init(); crate::loader::init();
crate::init_lua(); crate::init_lua();
CLIPBOARD.with(Default::default);
} }

View file

@ -34,15 +34,12 @@ impl Utils {
ya.raw_set( ya.raw_set(
"clipboard", "clipboard",
lua.create_async_function(|lua, text: mlua::String| async move { lua.create_async_function(|lua, text: Option<String>| async move {
let text = text.to_string_lossy().into_owned(); if let Some(text) = text {
if text.is_empty() {
let clipboard_data = CLIPBOARD.get().await;
Some(lua.create_string(clipboard_data.as_encoded_bytes())).transpose()
} else {
CLIPBOARD.set(text).await; CLIPBOARD.set(text).await;
Ok(None) Ok(None)
} else {
Some(lua.create_string(CLIPBOARD.get().await.as_encoded_bytes())).transpose()
} }
})?, })?,
)?; )?;