aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorFilip Dutescu2023-02-20 04:00:44 +0000
committerGitHub2023-02-20 04:00:44 +0000
commit44729fbaf9778b67869b2ed6b76b16b2354cc030 (patch)
tree29f2ee8557970917c704972a52025c3b0ed903d3 /helix-term
parente3765ac6d20195d2434c8274850247fe0a044da0 (diff)
fix(dap): validate key and index exist when requesting vars (#5628)
Check if the stack frames contain the thread id and the frame before trying to get the frame id. If case any of the two fails to be found, provide the user with messages to inform them of the issue and gracefully return. Closes: #5625 Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands/dap.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index b30dc8c0..023ed377 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -475,19 +475,36 @@ 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 = match debugger.stack_frames.get(&thread_id) {
+ Some(thread_frame) => thread_frame,
+ None => {
+ cx.editor
+ .set_error("Failed to get stack frame for thread: {thread_id}");
+ return;
+ }
+ };
+ let stack_frame = match thread_frame.get(frame) {
+ Some(stack_frame) => stack_frame,
+ None => {
+ cx.editor
+ .set_error("Failed to get stack frame for thread {thread_id} and frame {frame}.");
+ return;
+ }
+ };
+
+ let frame_id = stack_frame.id;
let scopes = match block_on(debugger.scopes(frame_id)) {
Ok(s) => s,
Err(e) => {