Allow forcing selection from the menu with <leader>F5

This commit is contained in:
Ben Jackson 2021-03-05 21:09:39 +00:00
commit 7723d58cf8
3 changed files with 11 additions and 3 deletions

View file

@ -41,11 +41,11 @@ function! s:Enabled() abort
return s:enabled
endfunction
function! vimspector#Launch() abort
function! vimspector#Launch( ... ) abort
if !s:Enabled()
return
endif
py3 _vimspector_session.Start()
py3 _vimspector_session.Start( *vim.eval( 'a:000' ) )
endfunction
function! vimspector#LaunchWithSettings( settings ) abort

View file

@ -35,6 +35,8 @@ let s:mappings = get( g:, 'vimspector_enable_mappings', '' )
nnoremap <silent> <Plug>VimspectorContinue
\ :<c-u>call vimspector#Continue()<CR>
nnoremap <silent> <Plug>VimspectorLaunch
\ :<c-u>call vimspector#Launch( v:true )<CR>
nnoremap <silent> <Plug>VimspectorStop
\ :<c-u>call vimspector#Stop()<CR>
nnoremap <silent> <Plug>VimspectorRestart
@ -79,6 +81,7 @@ if s:mappings ==# 'VISUAL_STUDIO'
nmap <S-F11> <Plug>VimspectorStepOut
elseif s:mappings ==# 'HUMAN'
nmap <F5> <Plug>VimspectorContinue
nmap <leader><F5> <Plug>VimspectorLaunch
nmap <F3> <Plug>VimspectorStop
nmap <F4> <Plug>VimspectorRestart
nmap <F6> <Plug>VimspectorPause

View file

@ -99,7 +99,7 @@ class DebugSession( object ):
return launch_config_file, configurations
def Start( self, launch_variables = None ):
def Start( self, force_choose=False, launch_variables = None ):
# We mutate launch_variables, so don't mutate the default argument.
# https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
if launch_variables is None:
@ -134,6 +134,11 @@ class DebugSession( object ):
if 'configuration' in launch_variables:
configuration_name = launch_variables.pop( 'configuration' )
elif force_choose:
# Always display the menu
configuration_name = utils.SelectFromList(
'Which launch configuration?',
sorted( configurations.keys() ) )
elif ( len( configurations ) == 1 and
next( iter( configurations.values() ) ).get( "autoselect", True ) ):
configuration_name = next( iter( configurations.keys() ) )