Delay configurationDone until we have received _responses_ to the breakpoint requests, as go server seems to require this

This commit is contained in:
Ben Jackson 2019-07-31 19:02:09 +01:00
commit b6a2e3df9e
2 changed files with 32 additions and 15 deletions

View file

@ -187,12 +187,22 @@ class ProjectBreakpoints( object ):
self._breakpoints_handler = handler self._breakpoints_handler = handler
def SendBreakpoints( self ): def SendBreakpoints( self, doneHandler = None ):
assert self._breakpoints_handler is not None assert self._breakpoints_handler is not None
# Clear any existing breakpoints prior to sending new ones # Clear any existing breakpoints prior to sending new ones
self._breakpoints_handler.ClearBreakpoints() self._breakpoints_handler.ClearBreakpoints()
awaiting = 0
def response_handler( source, msg ):
if msg:
self._breakpoints_handler.AddBreakpoints( source, msg )
nonlocal awaiting
awaiting = awaiting - 1
if awaiting == 0 and doneHandler:
doneHandler()
for file_name, line_breakpoints in self._line_breakpoints.items(): for file_name, line_breakpoints in self._line_breakpoints.items():
breakpoints = [] breakpoints = []
for bp in line_breakpoints: for bp in line_breakpoints:
@ -211,8 +221,9 @@ class ProjectBreakpoints( object ):
'path': file_name, 'path': file_name,
} }
awaiting = awaiting + 1
self._connection.DoRequest( self._connection.DoRequest(
lambda msg: self._breakpoints_handler.AddBreakpoints( source, msg ), lambda msg: response_handler( source, msg ),
{ {
'command': 'setBreakpoints', 'command': 'setBreakpoints',
'arguments': { 'arguments': {
@ -224,8 +235,9 @@ class ProjectBreakpoints( object ):
) )
if self._server_capabilities.get( 'supportsFunctionBreakpoints' ): if self._server_capabilities.get( 'supportsFunctionBreakpoints' ):
awaiting = awaiting + 1
self._connection.DoRequest( self._connection.DoRequest(
lambda msg: self._breakpoints_handler.AddBreakpoints( None, msg ), lambda msg: response_handler( None, msg ),
{ {
'command': 'setFunctionBreakpoints', 'command': 'setFunctionBreakpoints',
'arguments': { 'arguments': {
@ -241,14 +253,18 @@ class ProjectBreakpoints( object ):
self._SetUpExceptionBreakpoints() self._SetUpExceptionBreakpoints()
if self._exceptionBreakpoints: if self._exceptionBreakpoints:
awaiting = awaiting + 1
self._connection.DoRequest( self._connection.DoRequest(
None, # There is nothing on the response to this lambda msg: response_handler( None, None ),
{ {
'command': 'setExceptionBreakpoints', 'command': 'setExceptionBreakpoints',
'arguments': self._exceptionBreakpoints 'arguments': self._exceptionBreakpoints
} }
) )
if awaiting == 0 and doneHandler:
doneHandler()
def _SetUpExceptionBreakpoints( self ): def _SetUpExceptionBreakpoints( self ):
exceptionBreakpointFilters = self._server_capabilities.get( exceptionBreakpointFilters = self._server_capabilities.get(

View file

@ -683,18 +683,19 @@ class DebugSession( object ):
def OnEvent_initialized( self, message ): def OnEvent_initialized( self, message ):
self._codeView.ClearBreakpoints() def onBreakpointsDone():
self._breakpoints.SendBreakpoints() if self._server_capabilities.get( 'supportsConfigurationDoneRequest' ):
self._connection.DoRequest(
lambda msg: self._OnInitializeComplete(),
{
'command': 'configurationDone',
}
)
else:
self._OnInitializeComplete()
if self._server_capabilities.get( 'supportsConfigurationDoneRequest' ): self._codeView.ClearBreakpoints()
self._connection.DoRequest( self._breakpoints.SendBreakpoints( onBreakpointsDone )
lambda msg: self._OnInitializeComplete(),
{
'command': 'configurationDone',
}
)
else:
self._OnInitializeComplete()
def OnEvent_thread( self, message ): def OnEvent_thread( self, message ):
self._stackTraceView.OnThreadEvent( message[ 'body' ] ) self._stackTraceView.OnThreadEvent( message[ 'body' ] )