aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/dap.rs36
1 files changed, 32 insertions, 4 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 9509ada1..66127360 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -1,4 +1,5 @@
use super::{Context, Editor};
+use crate::ui::Picker;
use helix_dap::Client;
use helix_lsp::block_on;
@@ -221,7 +222,7 @@ pub fn dap_continue(cx: &mut Context) {
return;
}
- let request = debugger.continue_thread(debugger.stopped_thread.unwrap());
+ let request = debugger.continue_thread(debugger.thread_id.unwrap());
if let Err(e) = block_on(request) {
cx.editor.set_error(format!("Failed to continue: {:?}", e));
return;
@@ -254,7 +255,7 @@ pub fn dap_step_in(cx: &mut Context) {
return;
}
- let request = debugger.step_in(debugger.stopped_thread.unwrap());
+ let request = debugger.step_in(debugger.thread_id.unwrap());
if let Err(e) = block_on(request) {
cx.editor.set_error(format!("Failed to step: {:?}", e));
}
@@ -269,7 +270,7 @@ pub fn dap_step_out(cx: &mut Context) {
return;
}
- let request = debugger.step_out(debugger.stopped_thread.unwrap());
+ let request = debugger.step_out(debugger.thread_id.unwrap());
if let Err(e) = block_on(request) {
cx.editor.set_error(format!("Failed to step: {:?}", e));
}
@@ -284,7 +285,7 @@ pub fn dap_next(cx: &mut Context) {
return;
}
- let request = debugger.next(debugger.stopped_thread.unwrap());
+ let request = debugger.next(debugger.thread_id.unwrap());
if let Err(e) = block_on(request) {
cx.editor.set_error(format!("Failed to step: {:?}", e));
}
@@ -347,3 +348,30 @@ pub fn dap_terminate(cx: &mut Context) {
cx.editor.debugger = None;
}
}
+
+pub fn dap_switch_thread(cx: &mut Context) {
+ if let Some(debugger) = &mut cx.editor.debugger {
+ let request = debugger.threads();
+ let threads = match block_on(request) {
+ Ok(threads) => threads,
+ Err(e) => {
+ cx.editor
+ .set_error(format!("Failed to retrieve threads: {:?}", e));
+ return;
+ }
+ };
+
+ let picker = Picker::new(
+ true,
+ threads,
+ |thread| thread.name.clone().into(),
+ |editor, thread, _action| {
+ if let Some(debugger) = &mut editor.debugger {
+ debugger.thread_id = Some(thread.id);
+ // TODO: probably need to refetch stack frames?
+ }
+ },
+ );
+ cx.push_layer(Box::new(picker))
+ }
+}