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
# 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._next_sign_id += 1

View file

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

View file

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