fix: preserve UTF-8 clipboard text in native macOS launches
Verify Tessera GUI / verify (push) Failing after 7m14s
Verify Tessera GUI / verify (push) Failing after 7m14s
This commit is contained in:
+12
-23
@@ -105,31 +105,20 @@ impl TesseraApp {
|
||||
if command && let Key::Character(value) = &event.logical_key {
|
||||
match value.to_lowercase().as_str() {
|
||||
"a" => self.developer_tools.selection = true,
|
||||
"v" => {
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Ok(output) = std::process::Command::new("pbpaste").output()
|
||||
&& output.status.success()
|
||||
{
|
||||
self.developer_tools
|
||||
.insert(&String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
}
|
||||
"v" => match crate::clipboard::read() {
|
||||
Ok(value) => self.developer_tools.insert(&value),
|
||||
Err(error) => self.developer_tools.input_error = format!("Clipboard: {error}"),
|
||||
},
|
||||
"c" | "x" => {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use std::io::Write;
|
||||
let selected = self.developer_tools.selected_text();
|
||||
if !selected.is_empty()
|
||||
&& let Ok(mut child) = std::process::Command::new("pbcopy")
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
{
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
let _ = stdin.write_all(selected.as_bytes());
|
||||
let selected = self.developer_tools.selected_text();
|
||||
if !selected.is_empty() {
|
||||
match crate::clipboard::write(&selected) {
|
||||
Ok(()) if value.eq_ignore_ascii_case("x") => {
|
||||
self.developer_tools.insert("")
|
||||
}
|
||||
let _ = child.wait();
|
||||
if value.eq_ignore_ascii_case("x") {
|
||||
self.developer_tools.insert("");
|
||||
Ok(()) => {}
|
||||
Err(error) => {
|
||||
self.developer_tools.input_error = format!("Clipboard: {error}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user