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
1 changed files with 12 additions and 8 deletions
|
@ -66,6 +66,8 @@ pub fn init(cx: &mut AppContext) {
|
||||||
cx,
|
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>) {
|
fn spawn_task_or_modal(workspace: &mut Workspace, action: &Spawn, cx: &mut ViewContext<Workspace>) {
|
||||||
match &action.task_name {
|
match &action.task_name {
|
||||||
Some(name) => spawn_task_with_name(name.clone(), cx),
|
Some(name) => spawn_task_with_name(name.clone(), cx),
|
||||||
None => {
|
None => toggle_modal(workspace, cx),
|
||||||
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 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>) {
|
fn spawn_task_with_name(name: String, cx: &mut ViewContext<Workspace>) {
|
||||||
cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
let did_spawn = workspace
|
let did_spawn = workspace
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue