From ad3ca2c0c656b2b08296402e58d15c9d176ad1d7 Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Tue, 1 Jul 2025 15:35:12 -0700 Subject: [PATCH] fix windows paste bug. --- src-tauri/src/utils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 6dd752f..10b5b92 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -54,8 +54,16 @@ pub fn paste(text: String, app_handle: AppHandle) -> Result<(), String> { .write_text(&text) .map_err(|e| format!("Failed to write to clipboard: {}", e))?; + // Add a small delay on Windows to ensure clipboard write is complete + #[cfg(target_os = "windows")] + std::thread::sleep(std::time::Duration::from_millis(50)); + send_paste()?; + // Add another small delay before restoring clipboard + #[cfg(target_os = "windows")] + std::thread::sleep(std::time::Duration::from_millis(50)); + // restore the clipboard clipboard .write_text(&clipboard_content)