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.
pull/13796/head
Ashkan Kiani 2025-02-25 21:00:33 +08:00 committed by Ashkan Kiani
parent ac83b7709a
commit b92e1d15fe
1 changed files with 6 additions and 2 deletions

View File

@ -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)