task: Allow Rerun action to override properties of task being reran (#10468)
For example: ``` "alt-t": [ "task::Rerun", { "reevaluate_context": true, "allow_concurrent_runs": true } ], ``` Overriding `allow_concurrent_runs` to `true` by itself should terminate current instance of the task, if there's any. This PR also fixes task deduplication in terminal panel to use expanded label and not the id, which depends on task context. It kinda aligns with how task rerun worked prior to #10341 . That's omitted in the release notes though, as it's not in Preview yet. Release Notes: - `Task::Rerun` action can now override `allow_concurrent_runs` and `use_new_terminal` properties of the task that is being reran.
This commit is contained in:
parent
6e1ba7e936
commit
298e9c9387
4 changed files with 31 additions and 7 deletions
|
@ -23,13 +23,19 @@ pub fn init(cx: &mut AppContext) {
|
|||
workspace
|
||||
.register_action(spawn_task_or_modal)
|
||||
.register_action(move |workspace, action: &modal::Rerun, cx| {
|
||||
if let Some((task_source_kind, last_scheduled_task)) =
|
||||
if let Some((task_source_kind, mut last_scheduled_task)) =
|
||||
workspace.project().update(cx, |project, cx| {
|
||||
project.task_inventory().read(cx).last_scheduled_task()
|
||||
})
|
||||
{
|
||||
if action.reevaluate_context {
|
||||
let original_task = last_scheduled_task.original_task;
|
||||
let mut original_task = last_scheduled_task.original_task;
|
||||
if let Some(allow_concurrent_runs) = action.allow_concurrent_runs {
|
||||
original_task.allow_concurrent_runs = allow_concurrent_runs;
|
||||
}
|
||||
if let Some(use_new_terminal) = action.use_new_terminal {
|
||||
original_task.use_new_terminal = use_new_terminal;
|
||||
}
|
||||
let cwd = task_cwd(workspace, cx).log_err().flatten();
|
||||
let task_context = task_context(workspace, cwd, cx);
|
||||
schedule_task(
|
||||
|
@ -41,6 +47,15 @@ pub fn init(cx: &mut AppContext) {
|
|||
cx,
|
||||
)
|
||||
} else {
|
||||
if let Some(resolved) = last_scheduled_task.resolved.as_mut() {
|
||||
if let Some(allow_concurrent_runs) = action.allow_concurrent_runs {
|
||||
resolved.allow_concurrent_runs = allow_concurrent_runs;
|
||||
}
|
||||
if let Some(use_new_terminal) = action.use_new_terminal {
|
||||
resolved.use_new_terminal = use_new_terminal;
|
||||
}
|
||||
}
|
||||
|
||||
schedule_resolved_task(
|
||||
workspace,
|
||||
task_source_kind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue