@@ -87,8 +87,7 @@ dap.listeners.after.scopes[SUBSCRIPTION_ID] = function(session)
8787 if util .is_buf_valid (state .bufnr ) then
8888 if state .current_section == " scopes" then
8989 scopes .refresh ()
90- end
91- if state .current_section == " sessions" then
90+ elseif state .current_section == " sessions" then
9291 sessions .refresh ()
9392 end
9493 end
@@ -107,6 +106,20 @@ dap.listeners.after.scopes[SUBSCRIPTION_ID] = function(session)
107106 end
108107end
109108
109+ --- @type dap.RequestListener[]
110+ local continue = { " event_continued" , " continue" }
111+
112+ for _ , listener in ipairs (continue ) do
113+ dap .listeners .after [listener ][SUBSCRIPTION_ID ] = function ()
114+ -- Program is no longer stopped, refresh threads to prevent user from jumping to a no longer accurate location
115+ if state .current_section == " threads" then
116+ require (" dap-view.views" ).switch_to_view (" threads" )
117+ end
118+
119+ winbar .redraw_controls ()
120+ end
121+ end
122+
110123dap .listeners .after .variables [SUBSCRIPTION_ID ] = function ()
111124 if state .current_section == " watches" then
112125 require (" dap-view.views" ).switch_to_view (" watches" )
@@ -178,27 +191,28 @@ dap.listeners.after.event_terminated[SUBSCRIPTION_ID] = function()
178191 winbar .redraw_controls ()
179192end
180193
181- --- Refresh winbar on dap session state change events not having a dedicated event handler
182- local winbar_redraw_events = { " continue " , " disconnect" , " event_exited" , " event_stopped" , " restart" }
194+ --- @type dap.RequestListener[]
195+ local winbar_redraw = { " disconnect" , " event_exited" , " event_stopped" , " restart" }
183196
184- for _ , event in ipairs (winbar_redraw_events ) do
185- dap .listeners .after [event ][SUBSCRIPTION_ID ] = winbar .redraw_controls
197+ for _ , listener in ipairs (winbar_redraw ) do
198+ dap .listeners .after [listener ][SUBSCRIPTION_ID ] = winbar .redraw_controls
186199end
187200
188- local auto_open_events = { " attach" , " launch" }
201+ --- @type dap.RequestListener[]
202+ local auto_open = { " attach" , " launch" }
189203
190- for _ , event in ipairs (auto_open_events ) do
191- dap .listeners .before [event ][SUBSCRIPTION_ID ] = function ()
204+ for _ , listener in ipairs (auto_open ) do
205+ dap .listeners .before [listener ][SUBSCRIPTION_ID ] = function ()
192206 if setup .config .auto_toggle then
193207 require (" dap-view" ).open ()
194208 end
195209 end
196210end
197211
198- local auto_close_events = { " event_terminated" , " event_exited" }
212+ local auto_close = { " event_terminated" , " event_exited" }
199213
200- for _ , event in ipairs (auto_close_events ) do
201- dap .listeners .before [event ][SUBSCRIPTION_ID ] = function ()
214+ for _ , listener in ipairs (auto_close ) do
215+ dap .listeners .before [listener ][SUBSCRIPTION_ID ] = function ()
202216 if setup .config .auto_toggle then
203217 require (" dap-view" ).close ()
204218 end
0 commit comments