wip: start adding action

Julia Ryan created

Change summary

crates/editor/src/code_context_menus.rs | 28 +++++++++++++++-----------
crates/zed_actions/src/lib.rs           | 25 ++++++++++++++++++++++++
2 files changed, 41 insertions(+), 12 deletions(-)

Detailed changes

crates/editor/src/code_context_menus.rs 🔗

@@ -1446,18 +1446,22 @@ impl CodeActionsMenu {
                                                 .on_click(cx.listener(
                                                     move |editor, _, window, cx| {
                                                         cx.stop_propagation();
-                                                        if let Some(workspace) = editor.workspace()
-                                                        {
-                                                            workspace.update(cx, |this, cx| {
-                                                                // if let Some(panel) = this.panel::<DebugPanel>(cx) {
-                                                                //     let kind = todo!();
-                                                                //     let id = todo!();
-                                                                //     panel.update_in(cx, |panel, window, cx| {
-                                                                //         panel.go_to_scenario_definition(kind, scenario, id, window, cx)
-                                                                //     })?
-                                                                // }
-                                                            })
-                                                        }
+                                                        window.dispatch_action(
+                                                            zed_actions::OpenInDebugJson.boxed_clone(),
+                                                            cx,
+                                                        );
+                                                        // if let Some(workspace) = editor.workspace()
+                                                        // {
+                                                        //     workspace.update(cx, |this, cx| {
+                                                        //         // if let Some(panel) = this.panel::<DebugPanel>(cx) {
+                                                        //         //     let kind = todo!();
+                                                        //         //     let id = todo!();
+                                                        //         //     panel.update_in(cx, |panel, window, cx| {
+                                                        //         //         panel.go_to_scenario_definition(kind, scenario, id, window, cx)
+                                                        //         //     })?
+                                                        //         // }
+                                                        //     })
+                                                        // }
                                                     },
                                                 )),
                                             )

crates/zed_actions/src/lib.rs 🔗

@@ -471,3 +471,28 @@ actions!(
         OpenProjectDebugTasks,
     ]
 );
+
+/// Reruns the last task.
+#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
+#[action(namespace = debugger)]
+#[serde(deny_unknown_fields)]
+pub struct OpenInDebugJson {
+    /// Controls whether the task context is reevaluated prior to execution of a task.
+    /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task
+    /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
+    /// default: false
+    #[serde(default)]
+    pub reevaluate_context: bool,
+    /// Overrides `allow_concurrent_runs` property of the task being reran.
+    /// Default: null
+    #[serde(default)]
+    pub allow_concurrent_runs: Option<bool>,
+    /// Overrides `use_new_terminal` property of the task being reran.
+    /// Default: null
+    #[serde(default)]
+    pub scenario: Scenario,
+
+    /// If present, rerun the task with this ID, otherwise rerun the last task.
+    #[serde(skip)]
+    pub task_id: Option<String>,
+}