Store the current launch configuration rather than pass it arround

This allows me to play around with the launch sequence a bit more
freely, though it does lead to a cacheing issue.
This commit is contained in:
Ben Jackson 2018-05-26 18:50:47 +01:00
commit 2ffea55e93

View file

@ -42,6 +42,7 @@ class DebugSession( object ):
self._currentFrame = None self._currentFrame = None
self._breakpoints = defaultdict( dict ) self._breakpoints = defaultdict( dict )
self._configuration = None
def ToggleBreakpoint( self ): def ToggleBreakpoint( self ):
line, column = vim.current.window.cursor line, column = vim.current.window.cursor
@ -75,11 +76,10 @@ class DebugSession( object ):
if not configuration: if not configuration:
return return
configuration = launch_config[ configuration ] self._configuration = launch_config[ configuration ]
self._StartDebugAdapter( configuration[ 'adapter' ] ) self._StartDebugAdapter()
self._Initialise( configuration[ 'adapter' ], self._Initialise()
configuration[ 'configuration' ] )
self._SetUpUI() self._SetUpUI()
def OnChannelData( self, data ): def OnChannelData( self, data ):
@ -180,13 +180,13 @@ class DebugSession( object ):
self._codeView.SetCurrentFrame( frame ) self._codeView.SetCurrentFrame( frame )
self._variablesView.LoadScopes( frame ) self._variablesView.LoadScopes( frame )
def _StartDebugAdapter( self, adapter_config ): def _StartDebugAdapter( self ):
self._logger.info( 'Starting debug adapter with: {0}'.format( json.dumps( self._logger.info( 'Starting debug adapter with: {0}'.format( json.dumps(
adapter_config ) ) ) self._configuration[ 'adapter' ] ) ) )
channel_send_func = vim.bindeval( channel_send_func = vim.bindeval(
"vimspector#internal#job#StartDebugSession( {0} )".format( "vimspector#internal#job#StartDebugSession( {0} )".format(
json.dumps( adapter_config ) ) ) json.dumps( self._configuration[ 'adapter' ] ) ) )
self._connection = debug_adapter_connection.DebugAdapterConnection( self._connection = debug_adapter_connection.DebugAdapterConnection(
self, self,
@ -202,18 +202,15 @@ class DebugSession( object ):
self._connection.DoRequest( lambda msg: self._Launch( launch_config ), { self._connection.DoRequest( lambda msg: self._Launch( launch_config ), {
'command': 'initialize', 'command': 'initialize',
'arguments': { 'arguments': {
'adapterID': adapter_config.get( 'name', 'adapter' ), 'adapterID': self._configuration[ 'adapter' ].get( 'name', 'adapter' ),
'linesStartAt1': True, 'linesStartAt1': True,
'columnsStartAt1': True, 'columnsStartAt1': True,
'pathFormat': 'path', 'pathFormat': 'path',
}, },
} ) } )
def _Launch( self, launch_config ):
self._connection.DoRequest( None, { self._connection.DoRequest( None, {
'command': launch_config[ 'request' ], 'command': self._configuration[ 'configuration' ][ 'request' ],
'arguments': launch_config 'arguments': self._configuration[ 'configuration' ]
} ) } )
def _UpdateBreakpoints( self, message ): def _UpdateBreakpoints( self, message ):