on master help sign in
find main thread automatically if thread stopped is not known
e0180a4Dmitry Sharshakov
helix-term/src/application.rs+15−2
@@ -276,8 +276,21 @@ impl Application {
276 debugger.is_running = false;
276 debugger.is_running = false;
277
277
278 // whichever thread stops is made "current" (if no previously selected thread).
278 // whichever thread stops is made "current" (if no previously selected thread).
279− if let Some(thread_id) = thread_id {
279+ if thread_id.is_none() || all_threads_stopped.unwrap_or_default() {
280+ let main = debugger.threads().await.ok().and_then(|threads| {
281+ // Workaround for debugging Go tests. Main thread has * in beginning of its name
282+ let mut main =
283+ threads.iter().find(|t| t.name.starts_with('*')).cloned();
284+ if main.is_none() {
285+ main = threads.get(0).cloned();
286+ }
287+ main.map(|t| t.id)
288+ });
289+ if let Some(id) = main {
290+ select_thread_id(&mut self.editor, id, false).await;
291+ }
292+ } else {
280− select_thread_id(&mut self.editor, thread_id, false).await;
293+ select_thread_id(&mut self.editor, thread_id.unwrap(), false).await;
281 }
294 }
282
295
283 let scope = match thread_id {
296 let scope = match thread_id {