Only load threads after _both_ init and launch. Maybe this is the magic that works for all servers

This commit is contained in:
Ben Jackson 2019-02-04 15:05:00 +00:00
commit 85d2f10f32

View file

@ -57,6 +57,8 @@ class DebugSession( object ):
self._configuration = None self._configuration = None
self._attach_process = None self._attach_process = None
self._init_complete = False
self._launch_complete = False
vim.command( 'sign define vimspectorBP text==> texthl=Error' ) vim.command( 'sign define vimspectorBP text==> texthl=Error' )
vim.command( 'sign define vimspectorBPDisabled text=!> texthl=Warning' ) vim.command( 'sign define vimspectorBPDisabled text=!> texthl=Warning' )
@ -229,6 +231,9 @@ class DebugSession( object ):
json.dumps( self._attach_process ) ) ) json.dumps( self._attach_process ) ) )
self._attach_process = None self._attach_process = None
self._init_complete = False
self._launch_complete = False
if self._uiTab: if self._uiTab:
self._stackTraceView.Reset() self._stackTraceView.Reset()
self._variablesView.Reset() self._variablesView.Reset()
@ -381,6 +386,9 @@ class DebugSession( object ):
self._logger.info( 'Starting debug adapter with: {0}'.format( json.dumps( self._logger.info( 'Starting debug adapter with: {0}'.format( json.dumps(
self._adapter ) ) ) self._adapter ) ) )
self._init_complete = False
self._launch_complete = False
self._connection_type = 'job' self._connection_type = 'job'
if 'port' in self._adapter: if 'port' in self._adapter:
self._connection_type = 'channel' self._connection_type = 'channel'
@ -572,7 +580,7 @@ class DebugSession( object ):
# then starts to listen for thread events to detect new or terminated # then starts to listen for thread events to detect new or terminated
# threads. # threads.
# #
lambda msg: self._stackTraceView.LoadThreads( True ), lambda msg: self._OnLaunchComplete(),
{ {
'command': launch_config[ 'request' ], 'command': launch_config[ 'request' ],
'arguments': launch_config 'arguments': launch_config
@ -586,11 +594,22 @@ class DebugSession( object ):
self._codeView.AddBreakpoints( source, message[ 'body' ][ 'breakpoints' ] ) self._codeView.AddBreakpoints( source, message[ 'body' ][ 'breakpoints' ] )
self._codeView.ShowBreakpoints() self._codeView.ShowBreakpoints()
def _OnLaunchComplete( self ):
self._launch_complete = True
self._LoadThreadsIfReady()
def _OnInitializeComplete( self ):
self._init_complete = True
self._LoadThreadsIfReady()
def _LoadThreadsIfReady( self ):
if self._launch_complete and self._init_complete:
self._stackTraceView.LoadThreads( True )
def OnEvent_initialized( self, message ): def OnEvent_initialized( self, message ):
self._SendBreakpoints() self._SendBreakpoints()
self._connection.DoRequest( self._connection.DoRequest(
None, self._OnInitializeComplete(),
{ {
'command': 'configurationDone', 'command': 'configurationDone',
} }