From 0d437475b9ede5e423570294b7a6cdf71ab73ab2 Mon Sep 17 00:00:00 2001 From: JhonnyV-V Date: Tue, 2 Jul 2024 16:50:13 -0400 Subject: [PATCH] Revert "adding tests and updating readme" This reverts commit 2a86e7adac0119eb660f47544ad61d73fc9ac5e6. --- README.md | 11 --------- generator/src/copy.rs | 53 ------------------------------------------- 2 files changed, 64 deletions(-) diff --git a/README.md b/README.md index 0996f92..d565a30 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ - [Usage](#usage) - [Copy into the clipboard](#copy-into-the-clipboard) - [Copy into clipboard on Linux Wayland](#copy-into-clipboard-on-linux-wayland) - - [Copy into clipboard on WSL](#copy-into-clipboard-on-wsl) - [Save the snapshot](#save-the-snapshot) - [Highlight code block](#highlight-code-block) - [How to use](#how-to-use) @@ -170,14 +169,6 @@ Copy screenshots directly into the clipboard is cool, however, it doesn't work w If you using CodeSnap.nvim on wl-clipboard, you can refer [wl-clip-persist](https://github.com/Linus789/wl-clip-persist), it reads all the clipboard data into memory and then overwrites the clipboard with the data from our memory to persist copied data. - -#### Copy into clipboard on WSL -currently copy to clipboard in WSL works, but it has some potencial issues, inside of wsl normally is not possible to copy an image to the clipboard, -how this works in wsl at this moment is the following, we create an image in the /tmp directory, then we try to execute powershell commands -to copy the image to the clipboard -> [!WARNING] -> If the WSL distro name is not the default or the pretty_name/name in the /etc/os-release this feature will fai - ### Save the snapshot Of course, you can use `CodeSnapSave` command to save the snapshot to path where you defined it in `config.save_path` @@ -190,8 +181,6 @@ require("codesnap").setup({ -- parsed: "~/Pictures/CodeSnap_y-m-d_at_h:m:s.png" -- save_path = "~/Pictures/foo.png" -- parsed: "~/Pictures/foo.png" - -- if you are on wsl and do you want to use a windows path - -- save_path="/mnt/c/Users/user/Pictures/" save_path = ... }) ``` diff --git a/generator/src/copy.rs b/generator/src/copy.rs index dcec69d..420ffda 100644 --- a/generator/src/copy.rs +++ b/generator/src/copy.rs @@ -116,56 +116,3 @@ fn generate_random_filename() -> String { // Combine prefix, random part, and extension format!("codesnap_{}.png", random_part) } - -#[cfg(test)] -mod test { - use std::process::{Command, Stdio}; - - use super::copy_to_wsl_clipboard; - - #[test] - #[cfg(target_os = "linux")] - fn copy_to_wsl_test() -> std::result::Result<(), nvim_oxi::Error> { - - if !wsl::is_wsl() { - return Ok(()); - } - - //not sure about the best way to test this in a dynamic way - //dir example - //"\\\\wsl$\\DistroName\\\\home\\username\\path\\test.png"; - let src_path = "";// your director here - return copy_to_wsl_clipboard(src_path); - } - - #[test] - #[cfg(target_os = "linux")] - fn check_if_folder_exist() { - if !wsl::is_wsl() { - return; - } - - let os_linux_release = sys_info::linux_os_release().unwrap(); - let wsl_path = format!( - "\\\\wsl$\\{}", - os_linux_release.name() - ); - - println!("path {}", wsl_path); - - let powershell = Command::new("/mnt/c/Windows//System32/WindowsPowerShell/v1.0/powershell.exe") - .arg("-NoProfile") - .arg("-Command") - .arg(&format!("Test-Path -path \"{}\"", wsl_path)) - .stdout(Stdio::piped()) - .stderr(Stdio::null()) - .output(); - - let stdout = String::from_utf8(powershell.unwrap().stdout).unwrap(); - - println!("output {:?}", stdout); - println!("exist {}", stdout == "True\r\n"); - println!("does not exist {}", stdout == "False\r\n"); - } -} -