Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Fix tab title when using `!!` and disable rerun button for terminal tasks (#26122)
Dinoe600e71c1c4d
diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rsindex cd647936039..66f625a50f9 100644--- a/crates/project/src/terminals.rs+++ b/crates/project/src/terminals.rs@@ -273,6 +273,7 @@ impl Project {status: TaskStatus::Running,show_summary: spawn_task.show_summary,show_command: spawn_task.show_command,+ show_rerun: spawn_task.show_rerun,completion_rx,});diff --git a/crates/task/src/lib.rs b/crates/task/src/lib.rsindex 0470e1e3a28..70e6597a431 100644--- a/crates/task/src/lib.rs+++ b/crates/task/src/lib.rs@@ -58,6 +58,8 @@ pub struct SpawnInTerminal {pub show_summary: bool,/// Whether to show the command line in the task output.pub show_command: bool,+ /// Whether to show the rerun button in the terminal tab.+ pub show_rerun: bool,}/// A final form of the [`TaskTemplate`], that got resolved with a particular [`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.rsindex a25e407f100..84f762638c5 100644--- a/crates/task/src/task_template.rs+++ b/crates/task/src/task_template.rs@@ -255,6 +255,7 @@ impl TaskTemplate {shell: self.shell.clone(),show_summary: self.show_summary,show_command: self.show_command,+ show_rerun: true,}),})}diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rsindex 4658eb36437..e256366fe45 100644--- a/crates/terminal/src/terminal.rs+++ b/crates/terminal/src/terminal.rs@@ -643,6 +643,7 @@ pub struct TaskState {pub hide: HideStrategy,pub show_summary: bool,pub show_command: bool,+ pub show_rerun: bool,}/// A status of the current terminal tab's task.diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex bf371773b77..203620a5cb9 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -22,8 +22,8 @@ use terminal::{},terminal_settings::{self, CursorShape, TerminalBlink, TerminalSettings, WorkingDirectory},Clear, Copy, Event, MaybeNavigationTarget, Paste, ScrollLineDown, ScrollLineUp, ScrollPageDown,- ScrollPageUp, ScrollToBottom, ScrollToTop, ShowCharacterPalette, TaskStatus, Terminal,- TerminalBounds, ToggleViMode,+ ScrollPageUp, ScrollToBottom, ScrollToTop, ShowCharacterPalette, TaskState, TaskStatus,+ Terminal, TerminalBounds, ToggleViMode,};use terminal_element::{is_blank, TerminalElement};use terminal_panel::TerminalPanel;@@ -807,6 +807,33 @@ impl TerminalView {.children(Scrollbar::vertical(self.scrollbar_state.clone())),)}++ fn rerun_button(task: &TaskState) -> Option<IconButton> {+ if !task.show_rerun {+ return None;+ }++ let task_id = task.id.clone();+ Some(+ IconButton::new("rerun-icon", IconName::Rerun)+ .icon_size(IconSize::Small)+ .size(ButtonSize::Compact)+ .icon_color(Color::Default)+ .shape(ui::IconButtonShape::Square)+ .tooltip(Tooltip::text("Rerun task"))+ .on_click(move |_, window, cx| {+ window.dispatch_action(+ Box::new(zed_actions::Rerun {+ task_id: Some(task_id.0.clone()),+ allow_concurrent_runs: Some(true),+ use_new_terminal: Some(false),+ reevaluate_context: false,+ }),+ cx,+ );+ }),+ )+ }}fn subscribe_for_terminal_events(@@ -1220,44 +1247,26 @@ impl Item for TerminalView {fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement {let terminal = self.terminal().read(cx);let title = terminal.title(true);- let rerun_button = |task_id: task::TaskId| {- IconButton::new("rerun-icon", IconName::Rerun)- .icon_size(IconSize::Small)- .size(ButtonSize::Compact)- .icon_color(Color::Default)- .shape(ui::IconButtonShape::Square)- .tooltip(Tooltip::text("Rerun task"))- .on_click(move |_, window, cx| {- window.dispatch_action(- Box::new(zed_actions::Rerun {- task_id: Some(task_id.0.clone()),- allow_concurrent_runs: Some(true),- use_new_terminal: Some(false),- reevaluate_context: false,- }),- cx,- );- })- };let (icon, icon_color, rerun_button) = match terminal.task() {Some(terminal_task) => match &terminal_task.status {TaskStatus::Running => (IconName::Play,Color::Disabled,- Some(rerun_button(terminal_task.id.clone())),+ TerminalView::rerun_button(&terminal_task),),TaskStatus::Unknown => (IconName::Warning,Color::Warning,- Some(rerun_button(terminal_task.id.clone())),+ TerminalView::rerun_button(&terminal_task),),TaskStatus::Completed { success } => {- let rerun_button = rerun_button(terminal_task.id.clone());+ let rerun_button = TerminalView::rerun_button(&terminal_task);+if *success {- (IconName::Check, Color::Success, Some(rerun_button))+ (IconName::Check, Color::Success, rerun_button)} else {- (IconName::XCircle, Color::Error, Some(rerun_button))+ (IconName::XCircle, Color::Error, rerun_button)}}},diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rsindex 2c3b028f564..88adcb1855f 100644--- a/crates/vim/src/command.rs+++ b/crates/vim/src/command.rs@@ -1420,11 +1420,11 @@ impl ShellExec {cx.emit(workspace::Event::SpawnTask {action: Box::new(SpawnInTerminal {id: TaskId("vim".to_string()),- full_label: self.command.clone(),- label: self.command.clone(),+ full_label: command.clone(),+ label: command.clone(),command: command.clone(),args: Vec::new(),- command_label: self.command.clone(),+ command_label: command.clone(),cwd,env: HashMap::default(),use_new_terminal: true,@@ -1435,6 +1435,7 @@ impl ShellExec {shell,show_summary: false,show_command: false,+ show_rerun: false,}),});});