WIP: Try and remember that the server quit

This commit is contained in:
Ben Jackson 2019-02-02 15:49:22 +00:00
commit 32e16d9daf
4 changed files with 15 additions and 9 deletions

View file

@ -40,6 +40,7 @@ endfunction
function! s:_Send( msg ) abort function! s:_Send( msg ) abort
call ch_sendraw( s:ch, a:msg ) call ch_sendraw( s:ch, a:msg )
return 1
endfunction endfunction
function! vimspector#internal#channel#Timeout( id ) abort function! vimspector#internal#channel#Timeout( id ) abort

View file

@ -43,21 +43,22 @@ endfunction
function! s:_Send( msg ) abort function! s:_Send( msg ) abort
if ! exists( 's:job' ) if ! exists( 's:job' )
echom "Can't send message: Job was not initialised correctly" echom "Can't send message: Job was not initialised correctly"
return return 0
endif endif
if job_status( s:job ) != 'run' if job_status( s:job ) != 'run'
echom "Can't send message: Job is not running" echom "Can't send message: Job is not running"
return return 0
endif endif
let ch = job_getchannel( s:job ) let ch = job_getchannel( s:job )
if ch == 'channel fail' if ch == 'channel fail'
echom "Channel was closed unexpectedly!" echom "Channel was closed unexpectedly!"
return return 0
endif endif
call ch_sendraw( ch, a:msg ) call ch_sendraw( ch, a:msg )
return 1
endfunction endfunction
function! vimspector#internal#job#StartDebugSession( config ) abort function! vimspector#internal#job#StartDebugSession( config ) abort

View file

@ -56,11 +56,14 @@ class DebugAdapterConnection( object ):
'timer_start( {}, "vimspector#internal#channel#Timeout" )'.format( 'timer_start( {}, "vimspector#internal#channel#Timeout" )'.format(
timeout ) ) timeout ) )
self._outstanding_requests[ this_id ] = PendingRequest( msg, request = PendingRequest( msg,
handler, handler,
failure_handler, failure_handler,
expiry_id ) expiry_id )
self._SendMessage( msg ) self._outstanding_requests[ this_id ] = request
if not self._SendMessage( msg ):
self._AbortRequest( request, 'Unable to send message' )
def OnRequestTimeout( self, timer_id ): def OnRequestTimeout( self, timer_id ):
request_id = None request_id = None
@ -144,7 +147,7 @@ class DebugAdapterConnection( object ):
data = 'Content-Length: {0}\r\n\r\n{1}'.format( len( msg ), msg ) data = 'Content-Length: {0}\r\n\r\n{1}'.format( len( msg ), msg )
# self._logger.debug( 'Sending: {0}'.format( data ) ) # self._logger.debug( 'Sending: {0}'.format( data ) )
self._Write( data ) return self._Write( data )
def _ReadHeaders( self ): def _ReadHeaders( self ):
parts = self._buffer.split( bytes( '\r\n\r\n', 'utf-8' ), 1 ) parts = self._buffer.split( bytes( '\r\n\r\n', 'utf-8' ), 1 )

View file

@ -578,6 +578,7 @@ class DebugSession( object ):
def OnEvent_terminated( self, message ): def OnEvent_terminated( self, message ):
self.Clear() self.Clear()
self._connection = None
utils.UserMessage( "Debugging was terminated." ) utils.UserMessage( "Debugging was terminated." )
def _RemoveBreakpoints( self ): def _RemoveBreakpoints( self ):