Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasol committed Oct 8, 2023
1 parent 9b8ca81 commit cfba1f2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,25 @@ fn in_ssh_shell() -> bool {
}

pub fn copy_string_to_clipboard(content: String) -> Result<CopyType, ()> {
if in_ssh_shell() {
// We do not use copypasta_ext::osc52 module because we have enabled terminal raw mode, so we print with crossterm utilities
// Check https://github.com/timvisee/rust-clipboard-ext/blob/371df19d2f961882a21c957f396d1e24548d1f28/src/osc52.rs#L92
return match crossterm::execute!(
if in_ssh_shell()
&& crossterm::execute!(
io::stdout(),
Print(format!(
"\x1B]52;c;{}\x07",
general_purpose::STANDARD.encode(content)
general_purpose::STANDARD.encode(&content)
))
) {
Ok(_) => Ok(CopyType::OSC52),
Err(_) => Err(()),
};
} else if BinClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content.clone()))
)
.is_ok()
{
Ok(CopyType::Native)
} else if ForkClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content))
// We do not use copypasta_ext::osc52 module because we have enabled terminal raw mode, so we print with crossterm utilities
// Check https://github.com/timvisee/rust-clipboard-ext/blob/371df19d2f961882a21c957f396d1e24548d1f28/src/osc52.rs#L92
Ok(CopyType::OSC52)
} else if BinClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content.clone()))
.is_ok()
|| ForkClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content))
.is_ok()
{
Ok(CopyType::Native)
} else {
Expand Down

0 comments on commit cfba1f2

Please sign in to comment.