From 06bba0f74719b3c905e7951785f4f699049e3fe0 Mon Sep 17 00:00:00 2001 From: The Mist Date: Mon, 8 Jul 2024 04:59:35 -0400 Subject: [PATCH] [Fix] copy not working on Linux (#117) --- generator/src/copy_ascii.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/generator/src/copy_ascii.rs b/generator/src/copy_ascii.rs index 296437d..8eada2c 100644 --- a/generator/src/copy_ascii.rs +++ b/generator/src/copy_ascii.rs @@ -1,11 +1,12 @@ -use std::cmp::max; - use crate::{ code::{calc_max_line_number_length, calc_wh}, config::TakeSnapshotParams, }; use arboard::Clipboard; +#[cfg(target_os = "linux")] +use arboard::SetExtLinux; use nvim_oxi::Result; +use std::cmp::max; const SPACE_BOTH_SIDE: usize = 2; @@ -59,6 +60,17 @@ pub fn copy_ascii(params: TakeSnapshotParams) -> Result<()> { ); let ascii_snapshot = format!("{top_frame}{breadcrumbs}{code}{bottom_frame}"); + #[cfg(target_os = "linux")] + std::thread::spawn(move || { + Clipboard::new() + .unwrap() + .set() + .wait() + .text(ascii_snapshot) + .unwrap(); + }); + + #[cfg(not(target_os = "linux"))] Clipboard::new().unwrap().set_text(ascii_snapshot).unwrap(); Ok(())