From 85d2f10f32b0bab310406f9f70c5b7e740f0393f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Mon, 4 Feb 2019 15:05:00 +0000 Subject: [PATCH] Only load threads after _both_ init and launch. Maybe this is the magic that works for all servers --- python3/vimspector/debug_session.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 588b03963..9cca9b7ce 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -57,6 +57,8 @@ def __init__( self ): self._configuration = 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 vimspectorBPDisabled text=!> texthl=Warning' ) @@ -229,6 +231,9 @@ def _Reset( self ): json.dumps( self._attach_process ) ) ) self._attach_process = None + self._init_complete = False + self._launch_complete = False + if self._uiTab: self._stackTraceView.Reset() self._variablesView.Reset() @@ -381,6 +386,9 @@ def _StartDebugAdapter( self ): self._logger.info( 'Starting debug adapter with: {0}'.format( json.dumps( self._adapter ) ) ) + self._init_complete = False + self._launch_complete = False + self._connection_type = 'job' if 'port' in self._adapter: self._connection_type = 'channel' @@ -572,7 +580,7 @@ def _Launch( self ): # then starts to listen for thread events to detect new or terminated # threads. # - lambda msg: self._stackTraceView.LoadThreads( True ), + lambda msg: self._OnLaunchComplete(), { 'command': launch_config[ 'request' ], 'arguments': launch_config @@ -586,11 +594,22 @@ def _UpdateBreakpoints( self, source, message ): self._codeView.AddBreakpoints( source, message[ 'body' ][ 'breakpoints' ] ) 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 ): self._SendBreakpoints() self._connection.DoRequest( - None, + self._OnInitializeComplete(), { 'command': 'configurationDone', }