Don't change the value of equalalways
We were trying to avoid equalalways from changing the UI layout by unsetting it and resetting it after changes. However, re-setting equalalways actually resizes all the windows, so this never worked. Instead we judiciously use rightbelow, leftabove, etc. and specify the exact window sizes we want. As a side-effect we make the terminal sizing a little more pleasant by default, ensuring that it is no wider than 80 chars, and tries to use any remianing vertical space after reserving 80 chars for the code window.
This commit is contained in:
parent
b1fd15c56a
commit
7a9f75a06e
4 changed files with 49 additions and 40 deletions
|
|
@ -48,7 +48,7 @@ endfunction
|
|||
function! vimspector#internal#neoterm#Start( cmd, opts ) abort
|
||||
" Prepare current buffer to be turned into a term if curwin is not set
|
||||
if ! get( a:opts, 'curwin', 0 )
|
||||
let mods = ''
|
||||
let mods = 'rightbelow '
|
||||
if get( a:opts, 'vertical', 0 )
|
||||
let mods .= 'vertical '
|
||||
let mods .= get( a:opts, 'term_cols', '' )
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ set cpoptions&vim
|
|||
" }}}
|
||||
|
||||
function! vimspector#internal#term#Start( cmd, opts ) abort
|
||||
return term_start( a:cmd, a:opts )
|
||||
rightbelow return term_start( a:cmd, a:opts )
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#term#IsFinished( bufno ) abort
|
||||
|
|
|
|||
|
|
@ -233,24 +233,33 @@ class CodeView( object ):
|
|||
|
||||
if self._terminal_window is not None and self._terminal_window.valid:
|
||||
assert self._terminal_buffer_number
|
||||
window_for_start = self._terminal_window
|
||||
if ( self._terminal_window.buffer.number == self._terminal_buffer_number
|
||||
and int( utils.Call( 'vimspector#internal#{}term#IsFinished'.format(
|
||||
self._api_prefix ),
|
||||
self._terminal_buffer_number ) ) ):
|
||||
window_for_start = self._terminal_window
|
||||
options[ 'curwin' ] = 1
|
||||
else:
|
||||
options[ 'vertical' ] = 0
|
||||
|
||||
buffer_number = None
|
||||
terminal_window = None
|
||||
with utils.TemporaryVimOptions( { 'splitright': True,
|
||||
'equalalways': False } ):
|
||||
with utils.LetCurrentWindow( window_for_start ):
|
||||
buffer_number = int(
|
||||
utils.Call(
|
||||
'vimspector#internal#{}term#Start'.format( self._api_prefix ),
|
||||
args,
|
||||
options ) )
|
||||
terminal_window = vim.current.window
|
||||
with utils.LetCurrentWindow( window_for_start ):
|
||||
# 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 options[ 'vertical' ] and not options.get( 'curwin', 0 ):
|
||||
options[ 'term_cols' ] = max(
|
||||
min ( int( vim.eval( 'winwidth( 0 ) - 82' ) ), 80 ),
|
||||
10
|
||||
)
|
||||
|
||||
buffer_number = int(
|
||||
utils.Call(
|
||||
'vimspector#internal#{}term#Start'.format( self._api_prefix ),
|
||||
args,
|
||||
options ) )
|
||||
terminal_window = vim.current.window
|
||||
|
||||
if buffer_number is None or buffer_number <= 0:
|
||||
# TODO: Do something better like reject the request?
|
||||
|
|
|
|||
|
|
@ -487,39 +487,39 @@ class DebugSession( object ):
|
|||
self._codeView = code.CodeView( code_window, self._api_prefix )
|
||||
|
||||
# Call stack
|
||||
with utils.TemporaryVimOptions( { 'splitright': False,
|
||||
'equalalways': False, } ):
|
||||
vim.command( 'topleft vertical 50new' )
|
||||
stack_trace_window = vim.current.window
|
||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||
self._connection,
|
||||
stack_trace_window )
|
||||
vim.command( 'topleft vertical 50new' )
|
||||
stack_trace_window = vim.current.window
|
||||
one_third = int( vim.eval( 'winheight( 0 )' ) ) / 3
|
||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||
self._connection,
|
||||
stack_trace_window )
|
||||
|
||||
with utils.TemporaryVimOptions( { 'splitbelow': False,
|
||||
'eadirection': 'ver',
|
||||
'equalalways': True } ):
|
||||
# Watches
|
||||
vim.command( 'new' )
|
||||
watch_window = vim.current.window
|
||||
# Watches
|
||||
vim.command( 'leftabove new' )
|
||||
watch_window = vim.current.window
|
||||
|
||||
# Variables
|
||||
vim.command( 'new' )
|
||||
vars_window = vim.current.window
|
||||
# Variables
|
||||
vim.command( 'leftabove new' )
|
||||
vars_window = vim.current.window
|
||||
|
||||
self._variablesView = variables.VariablesView( self._connection,
|
||||
vars_window,
|
||||
watch_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( self._connection,
|
||||
vars_window,
|
||||
watch_window )
|
||||
|
||||
with utils.TemporaryVimOption( 'splitbelow', True ):
|
||||
vim.current.window = code_window
|
||||
|
||||
# Output/logging
|
||||
vim.command( '10new' )
|
||||
output_window = vim.current.window
|
||||
self._outputView = output.OutputView( self._connection,
|
||||
output_window,
|
||||
self._api_prefix )
|
||||
# Output/logging
|
||||
vim.current.window = code_window
|
||||
vim.command( 'rightbelow 10new' )
|
||||
output_window = vim.current.window
|
||||
self._outputView = output.OutputView( self._connection,
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue