mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-06 02:03:06 +03:00
Toggle tasks modal in task::Rerun, when no tasks have been scheduled (#11059)
Currently, when no tasks have been scheduled, the `task::Rerun` action does nothing. This PR adds a fallback, so when no tasks have been scheduled so far the `task::Rerun` action toggles the tasks modal https://github.com/zed-industries/zed/assets/471335/72f7a71e-cfa8-49db-a295-fb05b2e7c905 Release Notes: - Improved the `task::Rerun` action to toggle the tasks modal when no tasks have been scheduled so far
This commit is contained in:
parent
8006f69513
commit
1af1a9e8b3
@ -66,6 +66,8 @@ pub fn init(cx: &mut AppContext) {
|
||||
cx,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
toggle_modal(workspace, cx);
|
||||
};
|
||||
});
|
||||
},
|
||||
@ -76,17 +78,19 @@ pub fn init(cx: &mut AppContext) {
|
||||
fn spawn_task_or_modal(workspace: &mut Workspace, action: &Spawn, cx: &mut ViewContext<Workspace>) {
|
||||
match &action.task_name {
|
||||
Some(name) => spawn_task_with_name(name.clone(), cx),
|
||||
None => {
|
||||
let inventory = workspace.project().read(cx).task_inventory().clone();
|
||||
let workspace_handle = workspace.weak_handle();
|
||||
let task_context = task_context(workspace, cx);
|
||||
workspace.toggle_modal(cx, |cx| {
|
||||
TasksModal::new(inventory, task_context, workspace_handle, cx)
|
||||
})
|
||||
}
|
||||
None => toggle_modal(workspace, cx),
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_modal(workspace: &mut Workspace, cx: &mut ViewContext<'_, Workspace>) {
|
||||
let inventory = workspace.project().read(cx).task_inventory().clone();
|
||||
let workspace_handle = workspace.weak_handle();
|
||||
let task_context = task_context(workspace, cx);
|
||||
workspace.toggle_modal(cx, |cx| {
|
||||
TasksModal::new(inventory, task_context, workspace_handle, cx)
|
||||
})
|
||||
}
|
||||
|
||||
fn spawn_task_with_name(name: String, cx: &mut ViewContext<Workspace>) {
|
||||
cx.spawn(|workspace, mut cx| async move {
|
||||
let did_spawn = workspace
|
||||
|
Loading…
Reference in New Issue
Block a user