From b6a2e3df9e418ec405ea42ab1b657bfa74849147 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Wed, 31 Jul 2019 19:02:09 +0100 Subject: [PATCH] Delay configurationDone until we have received _responses_ to the breakpoint requests, as go server seems to require this --- python3/vimspector/breakpoints.py | 24 ++++++++++++++++++++---- python3/vimspector/debug_session.py | 23 ++++++++++++----------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/python3/vimspector/breakpoints.py b/python3/vimspector/breakpoints.py index 7973032..56f8170 100644 --- a/python3/vimspector/breakpoints.py +++ b/python3/vimspector/breakpoints.py @@ -187,12 +187,22 @@ class ProjectBreakpoints( object ): self._breakpoints_handler = handler - def SendBreakpoints( self ): + def SendBreakpoints( self, doneHandler = None ): assert self._breakpoints_handler is not None # Clear any existing breakpoints prior to sending new ones 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(): breakpoints = [] for bp in line_breakpoints: @@ -211,8 +221,9 @@ class ProjectBreakpoints( object ): 'path': file_name, } + awaiting = awaiting + 1 self._connection.DoRequest( - lambda msg: self._breakpoints_handler.AddBreakpoints( source, msg ), + lambda msg: response_handler( source, msg ), { 'command': 'setBreakpoints', 'arguments': { @@ -224,8 +235,9 @@ class ProjectBreakpoints( object ): ) if self._server_capabilities.get( 'supportsFunctionBreakpoints' ): + awaiting = awaiting + 1 self._connection.DoRequest( - lambda msg: self._breakpoints_handler.AddBreakpoints( None, msg ), + lambda msg: response_handler( None, msg ), { 'command': 'setFunctionBreakpoints', 'arguments': { @@ -241,14 +253,18 @@ class ProjectBreakpoints( object ): self._SetUpExceptionBreakpoints() if self._exceptionBreakpoints: + awaiting = awaiting + 1 self._connection.DoRequest( - None, # There is nothing on the response to this + lambda msg: response_handler( None, None ), { 'command': 'setExceptionBreakpoints', 'arguments': self._exceptionBreakpoints } ) + if awaiting == 0 and doneHandler: + doneHandler() + def _SetUpExceptionBreakpoints( self ): exceptionBreakpointFilters = self._server_capabilities.get( diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index a9dee09..64d14df 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -683,18 +683,19 @@ class DebugSession( object ): def OnEvent_initialized( self, message ): - self._codeView.ClearBreakpoints() - self._breakpoints.SendBreakpoints() + def onBreakpointsDone(): + 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._connection.DoRequest( - lambda msg: self._OnInitializeComplete(), - { - 'command': 'configurationDone', - } - ) - else: - self._OnInitializeComplete() + self._codeView.ClearBreakpoints() + self._breakpoints.SendBreakpoints( onBreakpointsDone ) def OnEvent_thread( self, message ): self._stackTraceView.OnThreadEvent( message[ 'body' ] )