Fix tracebacks when the debug adapter dies very quickly

This commit is contained in:
Ben Jackson 2020-01-02 23:55:46 +00:00
commit 37fefafe35
4 changed files with 28 additions and 14 deletions

View file

@ -30,7 +30,9 @@ endfunction
function! s:_OnExit( channel, status ) abort function! s:_OnExit( channel, status ) abort
echom 'Channel exit with status ' . a:status echom 'Channel exit with status ' . a:status
redraw redraw
unlet s:job if exists( 's:job' )
unlet s:job
endif
py3 _vimspector_session.OnServerExit( vim.eval( 'a:status' ) ) py3 _vimspector_session.OnServerExit( vim.eval( 'a:status' ) )
endfunction endfunction
@ -61,12 +63,17 @@ function! vimspector#internal#job#StartDebugSession( config ) abort
\ } \ }
\ ) \ )
echom 'Started job, status is: ' . job_status( s:job ) if !exists( 's:job' )
" The job died immediately after starting and we cleaned up
return v:false
endif
let status = job_status( s:job )
echom 'Started job, status is: ' . status
redraw redraw
if job_status( s:job ) !=# 'run' if status !=# 'run'
echom 'Unable to start job, status is: ' . job_status( s:job )
redraw
return v:false return v:false
endif endif
@ -140,7 +147,7 @@ function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
\ } ) ) \ } ) )
if job_status( s:commands[ a:category ][ index ] ) !=# 'run' if job_status( s:commands[ a:category ][ index ] ) !=# 'run'
echom 'Unable to start job for ' . a:cmd echom 'Unable to start job for ' . string( a:cmd )
redraw redraw
return v:none return v:none
endif endif

View file

@ -879,7 +879,11 @@ class DebugSession( object ):
status ) status )
self.Clear() self.Clear()
self._connection.Reset() if self._connection is not None:
# Can be None if the server dies _before_ StartDebugSession vim function
# returns
self._connection.Reset()
self._stackTraceView.ConnectionClosed() self._stackTraceView.ConnectionClosed()
self._variablesView.ConnectionClosed() self._variablesView.ConnectionClosed()
self._outputView.ConnectionClosed() self._outputView.ConnectionClosed()

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from vimspector import utils from vimspector import utils,install
import vim import vim
import json import json
@ -49,10 +49,7 @@ class OutputView( object ):
for b in set( BUFFER_MAP.values() ): for b in set( BUFFER_MAP.values() ):
self._CreateBuffer( b ) self._CreateBuffer( b )
self._CreateBuffer( self._CreateBuffer( 'Vimspector', file_name = utils.LOG_FILE )
'Vimspector',
file_name = vim.eval( 'expand( "~/.vimspector.log" )' ) )
self._ShowOutput( 'Console' ) self._ShowOutput( 'Console' )
def Print( self, categroy, text ): def Print( self, categroy, text ):
@ -161,6 +158,10 @@ class OutputView( object ):
if file_name is not None: if file_name is not None:
assert cmd is None assert cmd is None
if install.GetOS() == "windows":
# FIXME: Can't display fiels in windows (yet?)
return
cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ] cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ]
if cmd is not None: if cmd is not None:

View file

@ -23,8 +23,10 @@ import string
import functools import functools
_log_handler = logging.FileHandler( os.path.expanduser( '~/.vimspector.log' ), LOG_FILE = os.path.expanduser( os.path.join( '~', '.vimspector.log') )
mode = 'w' )
_log_handler = logging.FileHandler( LOG_FILE, mode = 'w' )
_log_handler.setFormatter( _log_handler.setFormatter(
logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ) ) logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ) )