Set syntax in stack trace too
This commit is contained in:
parent
db95fe0c1d
commit
19cc58f09e
4 changed files with 52 additions and 34 deletions
|
|
@ -483,6 +483,7 @@ class DebugSession( object ):
|
||||||
|
|
||||||
if frame:
|
if frame:
|
||||||
self._variablesView.SetSyntax( self._codeView.current_syntax )
|
self._variablesView.SetSyntax( self._codeView.current_syntax )
|
||||||
|
self._stackTraceView.SetSyntax( self._codeView.current_syntax )
|
||||||
self._variablesView.LoadScopes( frame )
|
self._variablesView.LoadScopes( frame )
|
||||||
self._variablesView.EvaluateWatches()
|
self._variablesView.EvaluateWatches()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,20 @@ class StackTraceView( object ):
|
||||||
self._session = session
|
self._session = session
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
||||||
self._currentThread = None
|
self._current_thread = None
|
||||||
self._currentFrame = None
|
self._current_frame = None
|
||||||
|
self._current_syntax = ""
|
||||||
|
|
||||||
self._threads = []
|
self._threads = []
|
||||||
self._sources = {}
|
self._sources = {}
|
||||||
|
|
||||||
utils.SetUpScratchBuffer( self._buf, 'vimspector.StackTrace' )
|
utils.SetUpScratchBuffer( self._buf, 'vimspector.StackTrace' )
|
||||||
|
|
||||||
vim.current.buffer = self._buf
|
vim.current.buffer = self._buf
|
||||||
|
# FIXME: Remove all usage of "Windown" and just use buffers to prevent all
|
||||||
|
# the bugs around the window being closed.
|
||||||
|
self._win = vim.current.window
|
||||||
|
|
||||||
vim.command( 'nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>' )
|
vim.command( 'nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>' )
|
||||||
|
|
||||||
self._line_to_frame = {}
|
self._line_to_frame = {}
|
||||||
|
|
@ -53,14 +59,15 @@ class StackTraceView( object ):
|
||||||
|
|
||||||
|
|
||||||
def GetCurrentThreadId( self ):
|
def GetCurrentThreadId( self ):
|
||||||
return self._currentThread
|
return self._current_thread
|
||||||
|
|
||||||
def GetCurrentFrame( self ):
|
def GetCurrentFrame( self ):
|
||||||
return self._currentFrame
|
return self._current_frame
|
||||||
|
|
||||||
def Clear( self ):
|
def Clear( self ):
|
||||||
self._currentFrame = None
|
self._current_frame = None
|
||||||
self._currentThread = None
|
self._current_thread = None
|
||||||
|
self._current_syntax = ""
|
||||||
self._threads = []
|
self._threads = []
|
||||||
self._sources = {}
|
self._sources = {}
|
||||||
with utils.ModifiableScratchBuffer( self._buf ):
|
with utils.ModifiableScratchBuffer( self._buf ):
|
||||||
|
|
@ -102,10 +109,10 @@ class StackTraceView( object ):
|
||||||
for thread in message[ 'body' ][ 'threads' ]:
|
for thread in message[ 'body' ][ 'threads' ]:
|
||||||
self._threads.append( thread )
|
self._threads.append( thread )
|
||||||
|
|
||||||
if infer_current_frame and thread[ 'id' ] == self._currentThread:
|
if infer_current_frame and thread[ 'id' ] == self._current_thread:
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
elif infer_current_frame and self._currentThread is None:
|
elif infer_current_frame and self._current_thread is None:
|
||||||
self._currentThread = thread[ 'id' ]
|
self._current_thread = thread[ 'id' ]
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
|
|
||||||
self._DrawThreads()
|
self._DrawThreads()
|
||||||
|
|
@ -170,8 +177,8 @@ class StackTraceView( object ):
|
||||||
def _JumpToFrame( self, frame ):
|
def _JumpToFrame( self, frame ):
|
||||||
def do_jump():
|
def do_jump():
|
||||||
if 'line' in frame and frame[ 'line' ] > 0:
|
if 'line' in frame and frame[ 'line' ] > 0:
|
||||||
self._currentFrame = frame
|
self._current_frame = frame
|
||||||
return self._session.SetCurrentFrame( self._currentFrame )
|
return self._session.SetCurrentFrame( self._current_frame )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
source = frame.get( 'source' ) or {}
|
source = frame.get( 'source' ) or {}
|
||||||
|
|
@ -188,32 +195,32 @@ class StackTraceView( object ):
|
||||||
|
|
||||||
def OnStopped( self, event ):
|
def OnStopped( self, event ):
|
||||||
if 'threadId' in event:
|
if 'threadId' in event:
|
||||||
self._currentThread = event[ 'threadId' ]
|
self._current_thread = event[ 'threadId' ]
|
||||||
elif event.get( 'allThreadsStopped', False ) and self._threads:
|
elif event.get( 'allThreadsStopped', False ) and self._threads:
|
||||||
self._currentThread = self._threads[ 0 ][ 'id' ]
|
self._current_thread = self._threads[ 0 ][ 'id' ]
|
||||||
|
|
||||||
if self._currentThread is not None:
|
if self._current_thread is not None:
|
||||||
for thread in self._threads:
|
for thread in self._threads:
|
||||||
if thread[ 'id' ] == self._currentThread:
|
if thread[ 'id' ] == self._current_thread:
|
||||||
self._LoadStackTrace( thread, True )
|
self._LoadStackTrace( thread, True )
|
||||||
return
|
return
|
||||||
|
|
||||||
self.LoadThreads( True )
|
self.LoadThreads( True )
|
||||||
|
|
||||||
def OnThreadEvent( self, event ):
|
def OnThreadEvent( self, event ):
|
||||||
if event[ 'reason' ] == 'started' and self._currentThread is None:
|
if event[ 'reason' ] == 'started' and self._current_thread is None:
|
||||||
self._currentThread = event[ 'threadId' ]
|
self._current_thread = event[ 'threadId' ]
|
||||||
self.LoadThreads( True )
|
self.LoadThreads( True )
|
||||||
|
|
||||||
def Continue( self ):
|
def Continue( self ):
|
||||||
if self._currentThread is None:
|
if self._current_thread is None:
|
||||||
utils.UserMessage( 'No current thread', persist = True )
|
utils.UserMessage( 'No current thread', persist = True )
|
||||||
return
|
return
|
||||||
|
|
||||||
self._session._connection.DoRequest( None, {
|
self._session._connection.DoRequest( None, {
|
||||||
'command': 'continue',
|
'command': 'continue',
|
||||||
'arguments': {
|
'arguments': {
|
||||||
'threadId': self._currentThread,
|
'threadId': self._current_thread,
|
||||||
},
|
},
|
||||||
} )
|
} )
|
||||||
|
|
||||||
|
|
@ -221,14 +228,14 @@ class StackTraceView( object ):
|
||||||
self.LoadThreads( True )
|
self.LoadThreads( True )
|
||||||
|
|
||||||
def Pause( self ):
|
def Pause( self ):
|
||||||
if self._currentThread is None:
|
if self._current_thread is None:
|
||||||
utils.UserMessage( 'No current thread', persist = True )
|
utils.UserMessage( 'No current thread', persist = True )
|
||||||
return
|
return
|
||||||
|
|
||||||
self._session._connection.DoRequest( None, {
|
self._session._connection.DoRequest( None, {
|
||||||
'command': 'pause',
|
'command': 'pause',
|
||||||
'arguments': {
|
'arguments': {
|
||||||
'threadId': self._currentThread,
|
'threadId': self._current_thread,
|
||||||
},
|
},
|
||||||
} )
|
} )
|
||||||
|
|
||||||
|
|
@ -294,3 +301,8 @@ class StackTraceView( object ):
|
||||||
'source': source
|
'source': source
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
|
|
||||||
|
def SetSyntax( self, syntax ):
|
||||||
|
self._current_syntax = utils.SetSyntax( self._current_syntax,
|
||||||
|
syntax,
|
||||||
|
self._win )
|
||||||
|
|
|
||||||
|
|
@ -501,3 +501,17 @@ def memoize( func ):
|
||||||
@memoize
|
@memoize
|
||||||
def Exists( expr ):
|
def Exists( expr ):
|
||||||
return int( vim.eval( f'exists( "{ expr }" )' ) )
|
return int( vim.eval( f'exists( "{ expr }" )' ) )
|
||||||
|
|
||||||
|
|
||||||
|
def SetSyntax( current_syntax, syntax, *args ):
|
||||||
|
if not syntax:
|
||||||
|
syntax = ''
|
||||||
|
|
||||||
|
if current_syntax == syntax:
|
||||||
|
return
|
||||||
|
|
||||||
|
for win in args:
|
||||||
|
with LetCurrentWindow( win ):
|
||||||
|
vim.command( 'set syntax={}'.format( Escape( syntax ) ) )
|
||||||
|
|
||||||
|
return syntax
|
||||||
|
|
|
||||||
|
|
@ -387,18 +387,9 @@ class VariablesView( object ):
|
||||||
|
|
||||||
|
|
||||||
def SetSyntax( self, syntax ):
|
def SetSyntax( self, syntax ):
|
||||||
if not syntax:
|
self._current_syntax = utils.SetSyntax( self._current_syntax,
|
||||||
syntax = ''
|
syntax,
|
||||||
|
self._vars.win,
|
||||||
if self._current_syntax == syntax:
|
self._watch.win )
|
||||||
return
|
|
||||||
|
|
||||||
self._current_syntax = syntax
|
|
||||||
|
|
||||||
with utils.LetCurrentWindow( self._vars.win ):
|
|
||||||
vim.command( 'set syntax={}'.format( utils.Escape( syntax ) ) )
|
|
||||||
|
|
||||||
with utils.LetCurrentWindow( self._watch.win ):
|
|
||||||
vim.command( 'set syntax={}'.format( utils.Escape( syntax ) ) )
|
|
||||||
|
|
||||||
# vim: sw=2
|
# vim: sw=2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue