Skip to content

Commit 45bb8a7

Browse files
louisbourqueextrawurst
authored andcommitted
Fix freeze on copy when xclip is installed on Linux
1 parent f8e1c26 commit 45bb8a7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
* crash on branches popup in small terminal ([#1470](https://github.com/extrawurst/gitui/issues/1470))
3939
* `edit` command duplication ([#1489](https://github.com/extrawurst/gitui/issues/1489))
4040
* syntax errors in `key_bindings.ron` will be logged ([#1491](https://github.com/extrawurst/gitui/issues/1491))
41+
* Fix UI freeze when copying with xclip installed on Linux ([#1497](https://github.com/extrawurst/gitui/issues/1497))
4142
* commit hooks report "command not found" on Windows with wsl2 installed ([#1528](https://github.com/extrawurst/gitui/issues/1528))
4243
* crashes on entering submodules ([#1510](https://github.com/extrawurst/gitui/issues/1510))
4344
* fix race issue: revlog messages sometimes appear empty ([#1473](https://github.com/extrawurst/gitui/issues/1473))

src/clipboard.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn exec_copy_with_args(
88
command: &str,
99
args: &[&str],
1010
text: &str,
11+
pipe_stderr: bool,
1112
) -> Result<()> {
1213
let binary = which(command)
1314
.ok()
@@ -17,7 +18,11 @@ fn exec_copy_with_args(
1718
.args(args)
1819
.stdin(Stdio::piped())
1920
.stdout(Stdio::null())
20-
.stderr(Stdio::piped())
21+
.stderr(if pipe_stderr {
22+
Stdio::piped()
23+
} else {
24+
Stdio::null()
25+
})
2126
.spawn()
2227
.map_err(|e| anyhow!("`{:?}`: {}", command, e))?;
2328

@@ -45,7 +50,7 @@ fn exec_copy_with_args(
4550
}
4651

4752
fn exec_copy(command: &str, text: &str) -> Result<()> {
48-
exec_copy_with_args(command, &[], text)
53+
exec_copy_with_args(command, &[], text, true)
4954
}
5055

5156
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
@@ -58,10 +63,16 @@ pub fn copy_string(text: &str) -> Result<()> {
5863
"xclip",
5964
&["-selection", "clipboard"],
6065
text,
66+
false,
6167
)
6268
.is_err()
6369
{
64-
return exec_copy_with_args("xsel", &["--clipboard"], text);
70+
return exec_copy_with_args(
71+
"xsel",
72+
&["--clipboard"],
73+
text,
74+
true,
75+
);
6576
}
6677

6778
Ok(())

0 commit comments

Comments
 (0)