diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 0817330c8b96fe0ddc601cfd242d97a0d13875c8..5dad3caf4c44f96e1dfe1844e720f7d464797dd4 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -31,6 +31,7 @@ "ctrl-,": "zed::OpenSettings", "ctrl-q": "zed::Quit", "f4": "debugger::Start", + "alt-f4": "debugger::RerunLastSession", "f5": "debugger::Continue", "shift-f5": "debugger::Stop", "ctrl-shift-f5": "debugger::Restart", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 0bd87532332765f09ea12fa6d96a06b358f46615..d3502baead4b1a1d002eb438b0ecee0507f23b7f 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -4,6 +4,7 @@ "use_key_equivalents": true, "bindings": { "f4": "debugger::Start", + "alt-f4": "debugger::RerunLastSession", "f5": "debugger::Continue", "shift-f5": "debugger::Stop", "shift-cmd-f5": "debugger::Restart", diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index f9df107e3a56fffa376db1187e888f70caeae9cc..8fb006de747af2229e422d827a0aafacb5650a51 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -322,6 +322,45 @@ impl DebugPanel { .detach_and_log_err(cx); } + pub(crate) fn rerun_last_session( + &mut self, + workspace: &mut Workspace, + window: &mut Window, + cx: &mut Context, + ) { + let task_store = workspace.project().read(cx).task_store().clone(); + let Some(task_inventory) = task_store.read(cx).task_inventory() else { + return; + }; + let Some(scenario) = task_inventory.read(cx).last_scheduled_scenario().cloned() else { + return; + }; + let workspace = self.workspace.clone(); + + cx.spawn_in(window, async move |this, cx| { + let task_contexts = workspace + .update_in(cx, |workspace, window, cx| { + tasks_ui::task_contexts(workspace, window, cx) + })? + .await; + + let task_context = task_contexts.active_context().cloned().unwrap_or_default(); + let worktree_id = task_contexts.worktree(); + + this.update_in(cx, |this, window, cx| { + this.start_session( + scenario.clone(), + task_context, + None, + worktree_id, + window, + cx, + ); + }) + }) + .detach(); + } + pub(crate) async fn register_session( this: WeakEntity, session: Entity, diff --git a/crates/debugger_ui/src/debugger_ui.rs b/crates/debugger_ui/src/debugger_ui.rs index a317df4147c6aaba34300344dc6b59ba7ba62118..3676cec27fb997bf2b8c903dd681677366c35a76 100644 --- a/crates/debugger_ui/src/debugger_ui.rs +++ b/crates/debugger_ui/src/debugger_ui.rs @@ -47,6 +47,7 @@ actions!( ShowStackTrace, ToggleThreadPicker, ToggleSessionPicker, + RerunLastSession, ] ); @@ -208,7 +209,18 @@ pub fn init(cx: &mut App) { ) .register_action(|workspace: &mut Workspace, _: &Start, window, cx| { NewSessionModal::show(workspace, window, cx); - }); + }) + .register_action( + |workspace: &mut Workspace, _: &RerunLastSession, window, cx| { + let Some(debug_panel) = workspace.panel::(cx) else { + return; + }; + + debug_panel.update(cx, |debug_panel, cx| { + debug_panel.rerun_last_session(workspace, window, cx); + }) + }, + ); }) }) .detach(); diff --git a/crates/project/src/task_inventory.rs b/crates/project/src/task_inventory.rs index c779f4e0d71ddd881d1b7a54e7889dd4db17628f..44363eb7eb53f8216505cbadb15682b21ba9933f 100644 --- a/crates/project/src/task_inventory.rs +++ b/crates/project/src/task_inventory.rs @@ -230,6 +230,10 @@ impl Inventory { } } + pub fn last_scheduled_scenario(&self) -> Option<&DebugScenario> { + self.last_scheduled_scenarios.back() + } + pub fn list_debug_scenarios( &self, task_contexts: &TaskContexts,