diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/clipboard.rs | 17 |
2 files changed, 15 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 934cf18f..c8c3ff18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * crash on branches popup in small terminal ([#1470](https://github.com/extrawurst/gitui/issues/1470)) * `edit` command duplication ([#1489](https://github.com/extrawurst/gitui/issues/1489)) * syntax errors in `key_bindings.ron` will be logged ([#1491](https://github.com/extrawurst/gitui/issues/1491)) +* Fix UI freeze when copying with xclip installed on Linux ([#1497](https://github.com/extrawurst/gitui/issues/1497)) * commit hooks report "command not found" on Windows with wsl2 installed ([#1528](https://github.com/extrawurst/gitui/issues/1528)) * crashes on entering submodules ([#1510](https://github.com/extrawurst/gitui/issues/1510)) * fix race issue: revlog messages sometimes appear empty ([#1473](https://github.com/extrawurst/gitui/issues/1473)) diff --git a/src/clipboard.rs b/src/clipboard.rs index 61170fe2..2d492701 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -8,6 +8,7 @@ fn exec_copy_with_args( command: &str, args: &[&str], text: &str, + pipe_stderr: bool, ) -> Result<()> { let binary = which(command) .ok() @@ -17,7 +18,11 @@ fn exec_copy_with_args( .args(args) .stdin(Stdio::piped()) .stdout(Stdio::null()) - .stderr(Stdio::piped()) + .stderr(if pipe_stderr { + Stdio::piped() + } else { + Stdio::null() + }) .spawn() .map_err(|e| anyhow!("`{:?}`: {}", command, e))?; @@ -45,7 +50,7 @@ fn exec_copy_with_args( } fn exec_copy(command: &str, text: &str) -> Result<()> { - exec_copy_with_args(command, &[], text) + exec_copy_with_args(command, &[], text, true) } #[cfg(all(target_family = "unix", not(target_os = "macos")))] @@ -58,10 +63,16 @@ pub fn copy_string(text: &str) -> Result<()> { "xclip", &["-selection", "clipboard"], text, + false, ) .is_err() { - return exec_copy_with_args("xsel", &["--clipboard"], text); + return exec_copy_with_args( + "xsel", + &["--clipboard"], + text, + true, + ); } Ok(()) |