Add spawning of tasks without saving them in the task stack (#9951)
These tasks are not considered for reruns with `task::Rerun`. This PR tears a bunch of stuff up around tasks: - `menu::SecondaryConfirm` for tasks is gonna spawn a task without storing it in history instead of being occupied by oneshot tasks. This is done so that cmd-clicking on the menu item actually does something meaningful. - `menu::UseSelectedQuery` got moved into picker, as tasks are it's only user (and it doesn't really make sense as a menu action). TODO: - [x] add release note - [x] Actually implement the core of this feature, which is spawning a task without saving it in history, lol. Fixes #9804 Release Notes: - Added "fire-and-forget" task spawning; `menu::SecondaryConfirm` in tasks modal now spawns a task without registering it as the last spawned task for the purposes of `task::Rerun`. By default you can spawn a task in this fashion with cmd+enter or by holding cmd and clicking on a task entry in a list. Spawning oneshots has been rebound to `option-enter` (under a `picker::ConfirmInput` name). Fixes #9804 (breaking change) - Moved `menu::UseSelectedQuery` action to `picker` namespace (breaking change).
This commit is contained in:
parent
e7bd91c6c7
commit
cff9ad19f8
7 changed files with 104 additions and 38 deletions
|
|
@ -31,7 +31,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
old_context
|
||||
};
|
||||
|
||||
schedule_task(workspace, task.as_ref(), task_context, cx)
|
||||
schedule_task(workspace, task.as_ref(), task_context, false, cx)
|
||||
};
|
||||
});
|
||||
},
|
||||
|
|
@ -70,7 +70,7 @@ fn spawn_task_with_name(name: String, cx: &mut ViewContext<Workspace>) {
|
|||
let (_, target_task) = tasks.into_iter().find(|(_, task)| task.name() == name)?;
|
||||
let cwd = task_cwd(this, cx).log_err().flatten();
|
||||
let task_context = task_context(this, cwd, cx);
|
||||
schedule_task(this, target_task.as_ref(), task_context, cx);
|
||||
schedule_task(this, target_task.as_ref(), task_context, false, cx);
|
||||
Some(())
|
||||
})
|
||||
.ok()
|
||||
|
|
@ -195,15 +195,18 @@ fn schedule_task(
|
|||
workspace: &Workspace,
|
||||
task: &dyn Task,
|
||||
task_cx: TaskContext,
|
||||
omit_history: bool,
|
||||
cx: &mut ViewContext<'_, Workspace>,
|
||||
) {
|
||||
let spawn_in_terminal = task.exec(task_cx.clone());
|
||||
if let Some(spawn_in_terminal) = spawn_in_terminal {
|
||||
workspace.project().update(cx, |project, cx| {
|
||||
project.task_inventory().update(cx, |inventory, _| {
|
||||
inventory.task_scheduled(task.id().clone(), task_cx);
|
||||
})
|
||||
});
|
||||
if !omit_history {
|
||||
workspace.project().update(cx, |project, cx| {
|
||||
project.task_inventory().update(cx, |inventory, _| {
|
||||
inventory.task_scheduled(task.id().clone(), task_cx);
|
||||
})
|
||||
});
|
||||
}
|
||||
cx.emit(workspace::Event::SpawnTask(spawn_in_terminal));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue