The chrome debugger doesn't return 'line' in some stack frames. Fix a bug for expensive scopes

This commit is contained in:
Ben Jackson 2019-10-06 21:56:36 +01:00
commit 63f8543d8f
4 changed files with 30 additions and 9 deletions

View file

@ -73,7 +73,15 @@ class CodeView( object ):
return False return False
# SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows. # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows.
self._window.cursor = ( frame[ 'line' ], frame[ 'column' ] - 1 ) try:
self._window.cursor = ( frame[ 'line' ], frame[ 'column' ] - 1 )
except vim.error:
self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file "
"doesn't exist",
frame[ 'line' ],
frame[ 'column' ],
frame[ 'source' ][ 'path' ] )
return False
self._signs[ 'vimspectorPC' ] = self._next_sign_id self._signs[ 'vimspectorPC' ] = self._next_sign_id
self._next_sign_id += 1 self._next_sign_id += 1

View file

@ -162,8 +162,9 @@ class StackTraceView( object ):
self._LoadStackTrace( thread, False ) self._LoadStackTrace( thread, False )
def _JumpToFrame( self, frame ): def _JumpToFrame( self, frame ):
self._currentFrame = frame if 'line' in frame and frame[ 'line' ]:
return self._session.SetCurrentFrame( self._currentFrame ) self._currentFrame = frame
return self._session.SetCurrentFrame( self._currentFrame )
def OnStopped( self, event ): def OnStopped( self, event ):
if 'threadId' in event: if 'threadId' in event:
@ -226,10 +227,19 @@ class StackTraceView( object ):
if 'name' not in source: if 'name' not in source:
source[ 'name' ] = os.path.basename( source[ 'path' ] ) source[ 'name' ] = os.path.basename( source[ 'path' ] )
line = utils.AppendToBuffer( if frame.get( 'presentationHint' ) == 'label':
self._buf, # Sigh. FOr some reason, it's OK for debug adapters to completely ignore
' {0}: {1}@{2}:{3}'.format( frame[ 'id' ], # the protocol; it seems that the chrome adapter sets 'label' and
frame[ 'name' ], # doesn't set 'line'
source[ 'name' ], line = utils.AppendToBuffer(
frame[ 'line' ] ) ) self._buf,
' {0}: {1}'.format( frame[ 'id' ], frame[ 'name' ] ) )
else:
line = utils.AppendToBuffer(
self._buf,
' {0}: {1}@{2}:{3}'.format( frame[ 'id' ],
frame[ 'name' ],
source[ 'name' ],
frame[ 'line' ] ) )
self._line_to_frame[ line ] = frame self._line_to_frame[ line ] = frame

View file

@ -116,6 +116,8 @@ class VariablesView( object ):
elif not scope.get( 'expensive' ): elif not scope.get( 'expensive' ):
# Expand any non-expensive scope unless manually collapsed # Expand any non-expensive scope unless manually collapsed
scope[ '_expanded' ] = True scope[ '_expanded' ] = True
else:
scope[ '_expanded' ] = False
self._scopes.append( scope ) self._scopes.append( scope )
if scope[ '_expanded' ]: if scope[ '_expanded' ]:

View file

@ -2,6 +2,7 @@ $( document ).ready( function() {
var getMessage = function() { var getMessage = function() {
var msg = 'this is '; var msg = 'this is ';
msg += 'a test'; msg += 'a test';
msg += ' message';
return msg; return msg;
}; };