File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -657,7 +657,8 @@ function Session:update_threads(cb)
657
657
threads [thread .id ] = thread
658
658
local old_thread = self .threads [thread .id ]
659
659
if old_thread then
660
- thread .stopped = old_thread .stopped
660
+ local stopped = old_thread .stopped == nil and false or old_thread .stopped
661
+ thread .stopped = stopped
661
662
thread .frames = old_thread .frames
662
663
end
663
664
end
@@ -689,12 +690,24 @@ function Session:event_stopped(stopped)
689
690
local co = coroutine.running ()
690
691
691
692
if self .dirty .threads or (stopped .threadId and self .threads [stopped .threadId ] == nil ) then
693
+ local thread = {
694
+ id = stopped .threadId ,
695
+ name = " Unknown" ,
696
+ stopped = true
697
+ }
698
+ if thread .id then
699
+ self .threads [thread .id ] = thread
700
+ end
692
701
self :update_threads (coresume (co ))
693
702
local err = coroutine.yield ()
694
703
if err then
695
704
utils .notify (' Error retrieving threads: ' .. utils .fmt_error (err ), vim .log .levels .ERROR )
696
705
return
697
706
end
707
+ if thread .stopped == false then
708
+ log .debug (" Thread resumed during stopped event handling" , stopped , thread )
709
+ return
710
+ end
698
711
end
699
712
700
713
local should_jump = stopped .reason ~= ' pause' or stopped .allThreadsStopped
Original file line number Diff line number Diff line change @@ -322,6 +322,32 @@ describe('dap with fake server', function()
322
322
})
323
323
end )
324
324
325
+ it (" Doesn't jump on stopped if continue is received before threads response" , function ()
326
+ run_and_wait_until_initialized (config , server )
327
+ server .client .threads = function (self , request )
328
+ self :send_event (" continued" , {
329
+ threadId = 1 ,
330
+ })
331
+ self :send_response (request , {
332
+ threads = { { id = 1 , name = ' thread1' }, }
333
+ })
334
+ end
335
+ local log = require (' dap.log' ).create_logger (' dap.log' )
336
+ local debug = log .debug
337
+ local messages = {}
338
+ log .debug = function (...)
339
+ table.insert (messages , {... })
340
+ debug (... )
341
+ end
342
+ server .client :send_event (' stopped' , {
343
+ threadId = 1 ,
344
+ reason = ' unknown' ,
345
+ })
346
+ wait_for_response (server , " threads" )
347
+ wait (function () return # messages >= 5 end )
348
+ assert .are .same (" Thread resumed during stopped event handling" , messages [6 ][1 ])
349
+ end )
350
+
325
351
it (" Clears stopped state on continued event" , function ()
326
352
local buf = api .nvim_create_buf (true , false )
327
353
local win = api .nvim_get_current_win ()
You can’t perform that action at this time.
0 commit comments