Skip to content

Commit

Permalink
The chrome debugger doesn't return 'line' in some stack frames. Fix a…
Browse files Browse the repository at this point in the history
… bug for expensive scopes
  • Loading branch information
puremourning committed Oct 6, 2019
1 parent 52b0ee9 commit 63f8543
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
10 changes: 9 additions & 1 deletion python3/vimspector/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ def SetCurrentFrame( self, frame ):
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
Expand Down
26 changes: 18 additions & 8 deletions python3/vimspector/stack_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ def ExpandFrameOrThread( self ):
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:
Expand Down Expand Up @@ -226,10 +227,19 @@ def _DrawStackTrace( self, thread ):
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
2 changes: 2 additions & 0 deletions python3/vimspector/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def scopes_consumer( message ):
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' ]:
Expand Down
1 change: 1 addition & 0 deletions support/test/chrome/www/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $( document ).ready( function() {
var getMessage = function() {
var msg = 'this is ';
msg += 'a test';
msg += ' message';
return msg;
};

Expand Down

0 comments on commit 63f8543

Please sign in to comment.