From 930fc243f05fdf2e8fa40ccd559394c88e39c58c Mon Sep 17 00:00:00 2001 From: Rolo Date: Fri, 14 Jun 2024 01:17:27 -0700 Subject: [PATCH] refactor(commands): trim end of `pipe`-like output --- helix-term/src/commands.rs | 1 + helix-term/tests/test/commands.rs | 29 ++++++++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 5fc832351df3..e3e5c127f849 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -5760,6 +5760,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) { let fragment = range.slice(text); match shell_impl(shell, cmd, pipe.then(|| fragment.into())) { Ok(result) => { + let result = Tendril::from(result.trim_end()); if !pipe { shell_output = Some(result.clone()); } diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 7f41a2219acb..9f196827faf3 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -209,13 +209,10 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { "}, "|echo foo", indoc! {"\ - #[|foo\n]# - - #(|foo\n)# - - #(|foo\n)# - - "}, + #[|foo]# + #(|foo)# + #(|foo)#" + }, )) .await?; @@ -228,12 +225,9 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { "}, "!echo foo", indoc! {"\ - #[|foo\n]# - lorem - #(|foo\n)# - ipsum - #(|foo\n)# - dolor + #[|foo]#lorem + #(|foo)#ipsum + #(|foo)#dolor "}, )) .await?; @@ -247,12 +241,9 @@ async fn test_multi_selection_shell_commands() -> anyhow::Result<()> { "}, "echo foo", indoc! {"\ - lorem#[|foo\n]# - - ipsum#(|foo\n)# - - dolor#(|foo\n)# - + lorem#[|foo]# + ipsum#(|foo)# + dolor#(|foo)# "}, )) .await?;