diff options
author | Dmitry Sharshakov | 2021-09-02 08:08:24 +0000 |
---|---|---|
committer | Dmitry Sharshakov | 2021-09-02 08:08:24 +0000 |
commit | e0180a4b88172ea808f7a8f14b68f26cec441047 (patch) | |
tree | 350f3fbbcfaa5280eac14af266622899c3b3d9b8 | |
parent | 5b20f6020a4acd74bc545fc27c473f0198354e5d (diff) |
find main thread automatically if thread stopped is not known
-rw-r--r-- | helix-term/src/application.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 53919c8a..9e22e52b 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -276,8 +276,21 @@ impl Application { debugger.is_running = false; // whichever thread stops is made "current" (if no previously selected thread). - if let Some(thread_id) = thread_id { - select_thread_id(&mut self.editor, thread_id, false).await; + if thread_id.is_none() || all_threads_stopped.unwrap_or_default() { + let main = debugger.threads().await.ok().and_then(|threads| { + // Workaround for debugging Go tests. Main thread has * in beginning of its name + let mut main = + threads.iter().find(|t| t.name.starts_with('*')).cloned(); + if main.is_none() { + main = threads.get(0).cloned(); + } + main.map(|t| t.id) + }); + if let Some(id) = main { + select_thread_id(&mut self.editor, id, false).await; + } + } else { + select_thread_id(&mut self.editor, thread_id.unwrap(), false).await; } let scope = match thread_id { |