From e0180a4b88172ea808f7a8f14b68f26cec441047 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Thu, 2 Sep 2021 11:08:24 +0300 Subject: find main thread automatically if thread stopped is not known --- helix-term/src/application.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'helix-term/src') 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 { -- cgit v1.2.3-70-g09d2