diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index b3166e395d903..69e333dacc2d1 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -475,19 +475,32 @@ pub fn dap_variables(cx: &mut Context) { if debugger.thread_id.is_none() { cx.editor - .set_status("Cannot access variables while target is running"); + .set_status("Cannot access variables while target is running."); return; } let (frame, thread_id) = match (debugger.active_frame, debugger.thread_id) { (Some(frame), Some(thread_id)) => (frame, thread_id), _ => { cx.editor - .set_status("Cannot find current stack frame to access variables"); + .set_status("Cannot find current stack frame to access variables."); return; } }; - let frame_id = debugger.stack_frames[&thread_id][frame].id; + let thread_frame = debugger.stack_frames.get(&thread_id); + if let None = thread_frame { + cx.editor + .set_error("Failed to get stack frame for thread: {thread_id}"); + return; + } + let stack_frame = thread_frame.unwrap().get(frame); + if let None = stack_frame { + cx.editor + .set_error("Failed to get stack frame for thread {thread_id} and frame {frame}."); + return; + } + + let frame_id = stack_frame.unwrap().id; let scopes = match block_on(debugger.scopes(frame_id)) { Ok(s) => s, Err(e) => {