debugger: Extend f5 binding to contextually rerun the last session (#31753)

Release Notes:

- Debugger Beta: if there is no stopped or running session, `f5` now
reruns the last session, or opens the new session modal if there is no
previously-run session.
This commit is contained in:
Cole Miller 2025-06-02 20:35:52 -04:00 committed by GitHub
parent b14401f817
commit b16911e756
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 11 deletions

View file

@ -68,7 +68,7 @@ pub use persistence::{
use postage::stream::Stream;
use project::{
DirectoryLister, Project, ProjectEntryId, ProjectPath, ResolvedPath, Worktree, WorktreeId,
debugger::breakpoint_store::BreakpointStoreEvent,
debugger::{breakpoint_store::BreakpointStoreEvent, session::ThreadStatus},
};
use remote::{SshClientDelegate, SshConnectionOptions, ssh_session::ConnectionIdentifier};
use schemars::JsonSchema;
@ -161,6 +161,8 @@ pub trait DebuggerProvider {
fn task_scheduled(&self, cx: &mut App);
fn debug_scenario_scheduled(&self, cx: &mut App);
fn debug_scenario_scheduled_last(&self, cx: &App) -> bool;
fn active_thread_state(&self, cx: &App) -> Option<ThreadStatus>;
}
actions!(
@ -202,6 +204,7 @@ actions!(
Unfollow,
Welcome,
RestoreBanner,
ToggleExpandItem,
]
);
@ -5802,6 +5805,20 @@ impl Render for Workspace {
let mut context = KeyContext::new_with_defaults();
context.add("Workspace");
context.set("keyboard_layout", cx.keyboard_layout().name().to_string());
if let Some(status) = self
.debugger_provider
.as_ref()
.and_then(|provider| provider.active_thread_state(cx))
{
match status {
ThreadStatus::Running | ThreadStatus::Stepping => {
context.add("debugger_running");
}
ThreadStatus::Stopped => context.add("debugger_stopped"),
ThreadStatus::Exited | ThreadStatus::Ended => {}
}
}
let centered_layout = self.centered_layout
&& self.center.panes().len() == 1
&& self.active_item(cx).is_some();