fix windows paste bug.

This commit is contained in:
CJ Pais 2025-07-01 15:35:12 -07:00
parent 0805442bf2
commit ad3ca2c0c6

View file

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