From bc5927d5afc3487e4c6c83cb004709c81578ff33 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 30 Jun 2025 01:38:16 +0200 Subject: [PATCH] debugger: Fix spec violation with threads request being issued before debug session is initialized (#33627) Follow-up to #32852. This time we'll check if the debug session is initialized before querying threads. Release Notes: - Fix Zed's debugger issuing threads request before it is allowed to do so per DAP specification. --- crates/debugger_ui/src/debugger_panel.rs | 2 +- crates/debugger_ui/src/session/running/console.rs | 2 +- crates/project/src/debugger/session.rs | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 7490b50530ba026b4802d57140f66f248aadcb74..b2cd62134f2f8bcab82ed609d06117b7a0a0825a 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -868,7 +868,7 @@ impl DebugPanel { let threads = running_state.update(cx, |running_state, cx| { let session = running_state.session(); - session.read(cx).is_running().then(|| { + session.read(cx).is_started().then(|| { session.update(cx, |session, cx| { session.threads(cx) }) diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index 83d2d46547ada9da328cc44443813a87a6f681f1..aaac63640188b2b277d1ff8bfb9b75b114f5554b 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -114,7 +114,7 @@ impl Console { } fn is_running(&self, cx: &Context) -> bool { - self.session.read(cx).is_running() + self.session.read(cx).is_started() } fn handle_stack_frame_list_events( diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index 300c598bfb9e1daa198baecda0ce5ef5c08aa3e7..255a580e36aaa919a954307f46bba8dc13f44094 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -1037,10 +1037,6 @@ impl Session { matches!(self.mode, Mode::Building) } - pub fn is_running(&self) -> bool { - matches!(self.mode, Mode::Running(_)) - } - pub fn as_running_mut(&mut self) -> Option<&mut RunningMode> { match &mut self.mode { Mode::Running(local_mode) => Some(local_mode),