diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index 1320a883f3a0e1..111516c82de4cb 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -174,6 +174,8 @@ impl Project { command_label: spawn_task.command_label, hide: spawn_task.hide, status: TaskStatus::Running, + show_summary: spawn_task.show_summary, + show_command: spawn_task.show_command, completion_rx, }); diff --git a/crates/task/src/lib.rs b/crates/task/src/lib.rs index 534b77b743427f..cf3a414b112074 100644 --- a/crates/task/src/lib.rs +++ b/crates/task/src/lib.rs @@ -51,6 +51,10 @@ pub struct SpawnInTerminal { pub hide: HideStrategy, /// Which shell to use when spawning the task. pub shell: Shell, + /// Whether to show the task summary line in the task output (sucess/failure). + pub show_summary: bool, + /// Whether to show the command line in the task output. + pub show_command: bool, } /// A final form of the [`TaskTemplate`], that got resolved with a particualar [`TaskContext`] and now is ready to spawn the actual task. diff --git a/crates/task/src/task_template.rs b/crates/task/src/task_template.rs index b72a0d25f8b655..23a2bc8ca78473 100644 --- a/crates/task/src/task_template.rs +++ b/crates/task/src/task_template.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use util::serde::default_true; use anyhow::{bail, Context}; use collections::{HashMap, HashSet}; @@ -57,6 +58,12 @@ pub struct TaskTemplate { /// Which shell to use when spawning the task. #[serde(default)] pub shell: Shell, + /// Whether to show the task line in the task output. + #[serde(default = "default_true")] + pub show_summary: bool, + /// Whether to show the command line in the task output. + #[serde(default = "default_true")] + pub show_command: bool, } /// What to do with the terminal pane and tab, after the command was started. @@ -230,6 +237,8 @@ impl TaskTemplate { reveal: self.reveal, hide: self.hide, shell: self.shell.clone(), + show_summary: self.show_summary, + show_command: self.show_command, }), }) } diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 5a15723cee380e..6610ac567d522f 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -639,6 +639,8 @@ pub struct TaskState { pub status: TaskStatus, pub completion_rx: Receiver<()>, pub hide: HideStrategy, + pub show_summary: bool, + pub show_command: bool, } /// A status of the current terminal tab's task. @@ -1760,11 +1762,22 @@ impl Terminal { }; let (finished_successfully, task_line, command_line) = task_summary(task, error_code); - // SAFETY: the invocation happens on non `TaskStatus::Running` tasks, once, - // after either `AlacTermEvent::Exit` or `AlacTermEvent::ChildExit` events that are spawned - // when Zed task finishes and no more output is made. - // After the task summary is output once, no more text is appended to the terminal. - unsafe { append_text_to_term(&mut self.term.lock(), &[&task_line, &command_line]) }; + let mut lines_to_show = Vec::new(); + if task.show_summary { + lines_to_show.push(task_line.as_str()); + } + if task.show_command { + lines_to_show.push(command_line.as_str()); + } + + if !lines_to_show.is_empty() { + // SAFETY: the invocation happens on non `TaskStatus::Running` tasks, once, + // after either `AlacTermEvent::Exit` or `AlacTermEvent::ChildExit` events that are spawned + // when Zed task finishes and no more output is made. + // After the task summary is output once, no more text is appended to the terminal. + unsafe { append_text_to_term(&mut self.term.lock(), &lines_to_show) }; + } + match task.hide { HideStrategy::Never => {} HideStrategy::Always => { diff --git a/docs/src/tasks.md b/docs/src/tasks.md index 98cbd6dfc18eaa..f32e5778fcb737 100644 --- a/docs/src/tasks.md +++ b/docs/src/tasks.md @@ -41,7 +41,11 @@ Zed supports ways to spawn (and rerun) commands using its integrated terminal to // "args": ["--login"] // } // } - "shell": "system" + "shell": "system", + // Whether to show the task line in the output of the spawned task, defaults to `true`. + "show_summary": true, + // Whether to show the command line in the output of the spawned task, defaults to `true`. + "show_output": true } ] ```