on master help sign in
find main thread automatically if thread stopped is not known
commite0180a4b88172ea808f7a8f14b68f26cec441047 authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateThu 2 Sep 2021, 11:08 (5 years ago) parent5b20f60
1 file changed+15−2
helix-term/src/application.rs+15−2
helix-term/src/application.rs+15−2
@@ -276,8 +276,21 @@ impl Application {
276276 debugger.is_running = false;
277277
278278 // whichever thread stops is made "current" (if no previously selected thread).
279− if let Some(thread_id) = thread_id {
280− select_thread_id(&mut self.editor, thread_id, false).await;
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 {
293+ select_thread_id(&mut self.editor, thread_id.unwrap(), false).await;
281294 }
282295
283296 let scope = match thread_id {