Merge branch 'master' into master
This commit is contained in:
commit
2d589475eb
15 changed files with 709 additions and 50 deletions
|
|
@ -571,6 +571,14 @@ class DebugSession( object ):
|
|||
def ExpandFrameOrThread( self ):
|
||||
self._stackTraceView.ExpandFrameOrThread()
|
||||
|
||||
@IfConnected()
|
||||
def UpFrame( self ):
|
||||
self._stackTraceView.UpFrame()
|
||||
|
||||
@IfConnected()
|
||||
def DownFrame( self ):
|
||||
self._stackTraceView.DownFrame()
|
||||
|
||||
def ToggleLog( self ):
|
||||
if self._HasUI():
|
||||
return self.ShowOutput( 'Vimspector' )
|
||||
|
|
@ -655,6 +663,45 @@ class DebugSession( object ):
|
|||
vim.command( 'tab split' )
|
||||
self._uiTab = vim.current.tabpage
|
||||
|
||||
mode = settings.Get( 'ui_mode' )
|
||||
|
||||
if mode == 'auto':
|
||||
# Go vertical if there isn't enough horizontal space for at least:
|
||||
# the left bar width
|
||||
# + the code min width
|
||||
# + the terminal min width
|
||||
# + enough space for a sign column and number column?
|
||||
min_width = ( settings.Int( 'sidebar_width' )
|
||||
+ 1 + 2 + 3
|
||||
+ settings.Int( 'code_minwidth' )
|
||||
+ 1 + settings.Int( 'terminal_minwidth' ) )
|
||||
|
||||
min_height = ( settings.Int( 'code_minheight' ) + 1 +
|
||||
settings.Int( 'topbar_height' ) + 1 +
|
||||
settings.Int( 'bottombar_height' ) + 1 +
|
||||
2 )
|
||||
|
||||
mode = ( 'vertical'
|
||||
if vim.options[ 'columns' ] < min_width
|
||||
else 'horizontal' )
|
||||
|
||||
if vim.options[ 'lines' ] < min_height:
|
||||
mode = 'horizontal'
|
||||
|
||||
self._logger.debug( 'min_width/height: %s/%s, actual: %s/%s - result: %s',
|
||||
min_width,
|
||||
min_height,
|
||||
vim.options[ 'columns' ],
|
||||
vim.options[ 'lines' ],
|
||||
mode )
|
||||
|
||||
if mode == 'vertical':
|
||||
self._SetUpUIVertical()
|
||||
else:
|
||||
self._SetUpUIHorizontal()
|
||||
|
||||
|
||||
def _SetUpUIHorizontal( self ):
|
||||
# Code window
|
||||
code_window = vim.current.window
|
||||
self._codeView = code.CodeView( code_window, self._api_prefix )
|
||||
|
|
@ -695,6 +742,66 @@ class DebugSession( object ):
|
|||
# TODO: If/when we support multiple sessions, we'll need some way to
|
||||
# indicate which tab was created and store all the tabs
|
||||
vim.vars[ 'vimspector_session_windows' ] = {
|
||||
'mode': 'horizontal',
|
||||
'tabpage': self._uiTab.number,
|
||||
'code': utils.WindowID( code_window, self._uiTab ),
|
||||
'stack_trace': utils.WindowID( stack_trace_window, self._uiTab ),
|
||||
'variables': utils.WindowID( vars_window, self._uiTab ),
|
||||
'watches': utils.WindowID( watch_window, self._uiTab ),
|
||||
'output': utils.WindowID( output_window, self._uiTab ),
|
||||
'eval': None # this is going to be updated every time eval popup is opened
|
||||
}
|
||||
with utils.RestoreCursorPosition():
|
||||
with utils.RestoreCurrentWindow():
|
||||
with utils.RestoreCurrentBuffer( vim.current.window ):
|
||||
vim.command( 'doautocmd User VimspectorUICreated' )
|
||||
|
||||
|
||||
def _SetUpUIVertical( self ):
|
||||
# Code window
|
||||
code_window = vim.current.window
|
||||
self._codeView = code.CodeView( code_window, self._api_prefix )
|
||||
|
||||
# Call stack
|
||||
vim.command(
|
||||
f'topleft { settings.Int( "topbar_height" ) }new' )
|
||||
stack_trace_window = vim.current.window
|
||||
one_third = int( vim.eval( 'winwidth( 0 )' ) ) / 3
|
||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||
stack_trace_window )
|
||||
|
||||
|
||||
# Watches
|
||||
vim.command( 'leftabove vertical new' )
|
||||
watch_window = vim.current.window
|
||||
|
||||
# Variables
|
||||
vim.command( 'leftabove vertical new' )
|
||||
vars_window = vim.current.window
|
||||
|
||||
|
||||
with utils.LetCurrentWindow( vars_window ):
|
||||
vim.command( f'{ one_third }wincmd |' )
|
||||
with utils.LetCurrentWindow( watch_window ):
|
||||
vim.command( f'{ one_third }wincmd |' )
|
||||
with utils.LetCurrentWindow( stack_trace_window ):
|
||||
vim.command( f'{ one_third }wincmd |' )
|
||||
|
||||
self._variablesView = variables.VariablesView( vars_window,
|
||||
watch_window )
|
||||
|
||||
|
||||
# Output/logging
|
||||
vim.current.window = code_window
|
||||
vim.command( f'rightbelow { settings.Int( "bottombar_height" ) }new' )
|
||||
output_window = vim.current.window
|
||||
self._outputView = output.DAPOutputView( output_window,
|
||||
self._api_prefix )
|
||||
|
||||
# TODO: If/when we support multiple sessions, we'll need some way to
|
||||
# indicate which tab was created and store all the tabs
|
||||
vim.vars[ 'vimspector_session_windows' ] = {
|
||||
'mode': 'vertical',
|
||||
'tabpage': self._uiTab.number,
|
||||
'code': utils.WindowID( code_window, self._uiTab ),
|
||||
'stack_trace': utils.WindowID( stack_trace_window, self._uiTab ),
|
||||
|
|
|
|||
|
|
@ -20,11 +20,20 @@ from vimspector import utils
|
|||
|
||||
DEFAULTS = {
|
||||
# UI
|
||||
'bottombar_height': 10,
|
||||
'sidebar_width': 50,
|
||||
'code_minwidth': 82,
|
||||
'terminal_maxwidth': 80,
|
||||
'terminal_minwidth': 10,
|
||||
'ui_mode': 'auto',
|
||||
'bottombar_height': 10,
|
||||
|
||||
# For ui_mode = 'horizontal':
|
||||
'sidebar_width': 50,
|
||||
'code_minwidth': 82,
|
||||
'terminal_maxwidth': 80,
|
||||
'terminal_minwidth': 10,
|
||||
|
||||
# For ui_mode = 'vertical':
|
||||
'topbar_height': 15,
|
||||
'code_minheight': 20,
|
||||
'terminal_maxheight': 15,
|
||||
'terminal_minheight': 5,
|
||||
|
||||
# Signs
|
||||
'sign_priority': {
|
||||
|
|
|
|||
|
|
@ -367,6 +367,46 @@ class StackTraceView( object ):
|
|||
self._JumpToFrame( frame )
|
||||
|
||||
|
||||
|
||||
def _GetFrameOffset( self, delta ):
|
||||
thread: Thread
|
||||
for thread in self._threads:
|
||||
if thread.id != self._current_thread:
|
||||
continue
|
||||
|
||||
if not thread.stacktrace:
|
||||
return
|
||||
|
||||
frame_idx = None
|
||||
for index, frame in enumerate( thread.stacktrace ):
|
||||
if frame == self._current_frame:
|
||||
frame_idx = index
|
||||
break
|
||||
|
||||
if frame_idx is not None:
|
||||
target_idx = frame_idx + delta
|
||||
if target_idx >= 0 and target_idx < len( thread.stacktrace ):
|
||||
return thread.stacktrace[ target_idx ]
|
||||
|
||||
break
|
||||
|
||||
|
||||
def UpFrame( self ):
|
||||
frame = self._GetFrameOffset( 1 )
|
||||
if not frame:
|
||||
utils.UserMessage( 'Top of stack' )
|
||||
else:
|
||||
self._JumpToFrame( frame, 'up' )
|
||||
|
||||
|
||||
def DownFrame( self ):
|
||||
frame = self._GetFrameOffset( -1 )
|
||||
if not frame:
|
||||
utils.UserMessage( 'Bottom of stack' )
|
||||
else:
|
||||
self._JumpToFrame( frame, 'down' )
|
||||
|
||||
|
||||
def AnyThreadsRunning( self ):
|
||||
for thread in self._threads:
|
||||
if thread.state != Thread.TERMINATED:
|
||||
|
|
|
|||
|
|
@ -23,12 +23,53 @@ def LaunchTerminal( api_prefix,
|
|||
env = params.get( 'env' ) or {}
|
||||
|
||||
term_options = {
|
||||
'vertical': 1,
|
||||
'norestore': 1,
|
||||
'cwd': cwd,
|
||||
'env': env,
|
||||
}
|
||||
|
||||
if settings.Get( 'ui_mode' ) == 'horizontal':
|
||||
# force-horizontal
|
||||
term_options[ 'vertical' ] = 1
|
||||
elif utils.GetVimValue( vim.vars[ 'vimspector_session_windows' ],
|
||||
'mode' ) == 'horizontal':
|
||||
# horizontal, which means that we should have enough space for:
|
||||
# - sidebar
|
||||
# - code min
|
||||
# - term min width
|
||||
# - + 2 vertical spaders
|
||||
# - + 3 columns for signs
|
||||
term_options[ 'vertical' ] = 1
|
||||
|
||||
# if we don't have enough space for terminal_maxwidth, then see if we have
|
||||
# enough vertically for terminal_maxheight, in which case,
|
||||
# that seems a better fit
|
||||
term_horiz_max = ( settings.Int( 'sidebar_width' ) +
|
||||
1 + 2 + 3 +
|
||||
settings.Int( 'code_minwidth' ) +
|
||||
1 + settings.Int( 'terminal_maxwidth' ) )
|
||||
term_vert_max = ( settings.Int( 'bottombar_height' ) + 1 +
|
||||
settings.Int( 'code_minheight' ) + 1 +
|
||||
settings.Int( 'terminal_minheight' ) )
|
||||
|
||||
if ( vim.options[ 'columns' ] < term_horiz_max and
|
||||
vim.options[ 'lines' ] >= term_vert_max ):
|
||||
# Looks like it, let's try that layout
|
||||
term_options[ 'vertical' ] = 0
|
||||
|
||||
|
||||
else:
|
||||
# vertical - we need enough space horizontally for the code+terminal, but we
|
||||
# may fit better with code above terminal
|
||||
term_options[ 'vertical' ] = 0
|
||||
|
||||
term_horiz_max = ( settings.Int( 'code_minwidth' ) + 3 +
|
||||
settings.Int( 'terminal_maxwidth' ) + 1 )
|
||||
|
||||
if vim.options[ 'columns' ] > term_horiz_max:
|
||||
term_options[ 'vertical' ] = 1
|
||||
|
||||
|
||||
if not window_for_start or not window_for_start.valid:
|
||||
# TOOD: Where? Maybe we should just use botright vertical ...
|
||||
window_for_start = vim.current.window
|
||||
|
|
@ -50,13 +91,23 @@ def LaunchTerminal( api_prefix,
|
|||
# If we're making a vertical split from the code window, make it no more
|
||||
# than 80 columns and no fewer than 10. Also try and keep the code window
|
||||
# at least 82 columns
|
||||
if term_options[ 'vertical' ] and not term_options.get( 'curwin', 0 ):
|
||||
if term_options.get( 'curwin', 0 ):
|
||||
pass
|
||||
elif term_options[ 'vertical' ]:
|
||||
term_options[ 'term_cols' ] = max(
|
||||
min ( int( vim.eval( 'winwidth( 0 )' ) )
|
||||
- settings.Int( 'code_minwidth' ),
|
||||
settings.Int( 'terminal_maxwidth' ) ),
|
||||
settings.Int( 'terminal_minwidth' )
|
||||
)
|
||||
else:
|
||||
term_options[ 'term_rows' ] = max(
|
||||
min ( int( vim.eval( 'winheight( 0 )' ) )
|
||||
- settings.Int( 'code_minheight' ),
|
||||
settings.Int( 'terminal_maxheight' ) ),
|
||||
settings.Int( 'terminal_minheight' )
|
||||
)
|
||||
|
||||
|
||||
buffer_number = int(
|
||||
utils.Call(
|
||||
|
|
|
|||
|
|
@ -494,7 +494,6 @@ def _Substitute( template, mapping ):
|
|||
if mo.group( 'braceddefault' ) is not None:
|
||||
named = mo.group( 'defname' )
|
||||
if named not in mapping:
|
||||
''
|
||||
raise MissingSubstitution(
|
||||
named,
|
||||
mo.group( 'default' ).replace( '\\}', '}' ) )
|
||||
|
|
@ -536,8 +535,11 @@ def ExpandReferencesInString( orig_s,
|
|||
if default_value is None and e.default_value is not None:
|
||||
try:
|
||||
default_value = _Substitute( e.default_value, mapping )
|
||||
except MissingSubstitution:
|
||||
default_value = e.default_value
|
||||
except MissingSubstitution as e2:
|
||||
if e2.name in calculus:
|
||||
default_value = calculus[ e2.name ]()
|
||||
else:
|
||||
default_value = e.default_value
|
||||
|
||||
mapping[ key ] = AskForInput( 'Enter value for {}: '.format( key ),
|
||||
default_value )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue