vim: Fix tab title when using !!
and disable rerun button for terminal tasks (#26122)
These changes tackle two issues with running terminal commands via vim mode: - When using `!!` the tab's title was set to `!!` instead of the previous command that was run and these changes fix that in order to always display the previous command in the tab's title when re-running the command with `!!` - For a terminal command, pressing the rerun button would actually bring up the task palette, so this has been updated in order to disable the rerun button when the terminal tab was spawned via a vim command Closes #25800 Release Notes: - Fixed the terminal tab title when using `!!` to rerun the last command - Improved the terminal tab for when command is run via vim mode, in order to disable the rerun button, seeing as Zed does not support it
This commit is contained in:
parent
82d85fd2ed
commit
e600e71c1c
6 changed files with 44 additions and 29 deletions
|
@ -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,
|
||||
});
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -255,6 +255,7 @@ impl TaskTemplate {
|
|||
shell: self.shell.clone(),
|
||||
show_summary: self.show_summary,
|
||||
show_command: self.show_command,
|
||||
show_rerun: true,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue