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
echom 'Channel exit with status ' . a:status
redraw
unlet s:job
if exists( 's:job' )
unlet s:job
endif
py3 _vimspector_session.OnServerExit( vim.eval( 'a:status' ) )
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
if job_status( s:job ) !=# 'run'
echom 'Unable to start job, status is: ' . job_status( s:job )
redraw
if status !=# 'run'
return v:false
endif
@ -140,7 +147,7 @@ function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
\ } ) )
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
return v:none
endif

View file

@ -879,7 +879,11 @@ class DebugSession( object ):
status )
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._variablesView.ConnectionClosed()
self._outputView.ConnectionClosed()

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from vimspector import utils
from vimspector import utils,install
import vim
import json
@ -49,10 +49,7 @@ class OutputView( object ):
for b in set( BUFFER_MAP.values() ):
self._CreateBuffer( b )
self._CreateBuffer(
'Vimspector',
file_name = vim.eval( 'expand( "~/.vimspector.log" )' ) )
self._CreateBuffer( 'Vimspector', file_name = utils.LOG_FILE )
self._ShowOutput( 'Console' )
def Print( self, categroy, text ):
@ -161,6 +158,10 @@ class OutputView( object ):
if file_name is not 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 ]
if cmd is not None:

View file

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