From b92e1d15fec40236cb952fc5f6824cc9833fc366 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Tue, 25 Feb 2025 21:00:33 +0800 Subject: [PATCH] Change shell command output formatting Don't prepend markdown code block if the shell command has one already. This allows it to render however it wants instead of strictly sticking to [sh]. There is already the workaround of echoing [```] to close the existing block first, but that produces an extra blank line at the top that is ugly. --- helix-term/src/commands/typed.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 201058afb..91ac53f45 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2339,7 +2339,11 @@ fn run_shell_command( move |editor: &mut Editor, compositor: &mut Compositor| { if !output.is_empty() { let contents = ui::Markdown::new( - format!("```sh\n{}\n```", output.trim_end()), + if output.starts_with("```") { + output.trim_end().to_string() + } else { + format!("```sh\n{}\n```", output.trim_end()) + }, editor.syn_loader.clone(), ); let popup = Popup::new("shell", contents).position(Some( @@ -2347,7 +2351,7 @@ fn run_shell_command( )); compositor.replace_or_push("shell", popup); } - editor.set_status("Command run"); + // editor.set_status("Command run"); }, )); Ok(call)