diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 67ec6a1..c6a1f72 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -434,49 +434,59 @@ class DebugSession( object ): @IfConnected() def StepInto( self ): - if self._stackTraceView.GetCurrentThreadId() is None: + threadId = self._stackTraceView.GetCurrentThreadId() + if threadId is None: return - self._connection.DoRequest( None, { + def handler( *_ ): + self._stackTraceView.OnContinued( { 'threadId': threadId } ) + self._codeView.SetCurrentFrame( None ) + + self._connection.DoRequest( handler, { 'command': 'stepIn', 'arguments': { - 'threadId': self._stackTraceView.GetCurrentThreadId() + 'threadId': threadId }, } ) - self._stackTraceView.OnContinued() - self._codeView.SetCurrentFrame( None ) @IfConnected() def StepOut( self ): - if self._stackTraceView.GetCurrentThreadId() is None: + threadId = self._stackTraceView.GetCurrentThreadId() + if threadId is None: return - self._connection.DoRequest( None, { + def handler( *_ ): + self._stackTraceView.OnContinued( { 'threadId': threadId } ) + self._codeView.SetCurrentFrame( None ) + + self._connection.DoRequest( handler, { 'command': 'stepOut', 'arguments': { - 'threadId': self._stackTraceView.GetCurrentThreadId() + 'threadId': threadId }, } ) - self._stackTraceView.OnContinued() - self._codeView.SetCurrentFrame( None ) + def Continue( self ): if not self._connection: self.Start() return - if self._stackTraceView.GetCurrentThreadId() is None: + threadId = self._stackTraceView.GetCurrentThreadId() + if threadId is None: utils.UserMessage( 'No current thread', persist = True ) return - self._connection.DoRequest( None, { + def handler( *_ ): + self._stackTraceView.OnContinued( { 'threadId': threadId } ) + self._codeView.SetCurrentFrame( None ) + + self._connection.DoRequest( handler, { 'command': 'continue', 'arguments': { - 'threadId': self._stackTraceView.GetCurrentThreadId(), + 'threadId': threadId, }, } ) - self._stackTraceView.OnContinued() - self._codeView.SetCurrentFrame( None ) @IfConnected() def Pause( self ): diff --git a/python3/vimspector/stack_trace.py b/python3/vimspector/stack_trace.py index dd2662c..a0b4734 100644 --- a/python3/vimspector/stack_trace.py +++ b/python3/vimspector/stack_trace.py @@ -49,6 +49,7 @@ class Thread: def Continued( self ): self.state = Thread.RUNNING self.stopped_event = None + self.Collapse() def Exited( self ): self.state = Thread.TERMINATED @@ -56,7 +57,7 @@ class Thread: def State( self ): if self.state == Thread.PAUSED: - return self.stopped_event.get( 'description', 'paused' ) + return self.stopped_event.get( 'description' ) or 'paused' elif self.state == Thread.RUNNING: return 'running' return 'terminated' @@ -191,7 +192,7 @@ class StackTraceView( object ): self.LoadThreads( *self._pending_thread_request ) return - if not message[ 'body' ][ 'threads' ]: + if not ( message.get( 'body' ) or {} ).get( 'threads' ): # This is a protocol error. It is required to return at least one! utils.UserMessage( 'Protocol error: Server returned no threads', persist = False, @@ -372,12 +373,14 @@ class StackTraceView( object ): if thread is None: utils.UserMessage( 'No thread selected' ) elif thread.state == Thread.PAUSED: - self._session._connection.DoRequest( None, { - 'command': 'continue', - 'arguments': { - 'threadId': thread.id, - }, - } ) + self._session._connection.DoRequest( + lambda *_: self.OnContinued( { 'threadId': thread.id } ), + { + 'command': 'continue', + 'arguments': { + 'threadId': thread.id, + }, + } ) elif thread.state == Thread.RUNNING: self._session._connection.DoRequest( None, { 'command': 'pause',