Delay launching the python interpreter until needed

This commit is contained in:
Ben Jackson 2021-02-25 21:24:40 +00:00
commit f40ac5db23
2 changed files with 13 additions and 23 deletions

View file

@ -320,28 +320,6 @@ function! vimspector#CompleteOutput( ArgLead, CmdLine, CursorPos ) abort
return join( buffers, "\n" ) return join( buffers, "\n" )
endfunction endfunction
py3 <<EOF
def _vimspector_GetExprCompletions( ArgLead, prev_non_keyword_char ):
if not _vimspector_session:
return []
items = []
for candidate in _vimspector_session.GetCompletionsSync(
ArgLead,
prev_non_keyword_char ):
label = candidate.get( 'text', candidate[ 'label' ] )
start = prev_non_keyword_char - 1
if 'start' in candidate and 'length' in candidate:
start = candidate[ 'start' ]
items.append( ArgLead[ 0 : start ] + label )
return items
EOF
function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
if !s:Enabled() if !s:Enabled()
return return
@ -350,7 +328,7 @@ function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
let col = len( a:ArgLead ) let col = len( a:ArgLead )
let prev_non_keyword_char = match( a:ArgLead[ 0 : col - 1 ], '\k*$' ) + 1 let prev_non_keyword_char = match( a:ArgLead[ 0 : col - 1 ], '\k*$' ) + 1
return join( py3eval( '_vimspector_GetExprCompletions( ' return join( py3eval( '_vimspector_session.GetCommandLineCompletions( '
\ . 'vim.eval( "a:ArgLead" ), ' \ . 'vim.eval( "a:ArgLead" ), '
\ . 'int( vim.eval( "prev_non_keyword_char" ) ) )' ), \ . 'int( vim.eval( "prev_non_keyword_char" ) ) )' ),
\ "\n" ) \ "\n" )

View file

@ -628,6 +628,18 @@ class DebugSession( object ):
return response[ 'body' ][ 'targets' ] return response[ 'body' ][ 'targets' ]
@IfConnected( otherwise=[] )
def GetCommandLineCompletions( self, ArgLead, prev_non_keyword_char ):
items = []
for candidate in self.GetCompletionsSync( ArgLead, prev_non_keyword_char ):
label = candidate.get( 'text', candidate[ 'label' ] )
start = prev_non_keyword_char - 1
if 'start' in candidate and 'length' in candidate:
start = candidate[ 'start' ]
items.append( ArgLead[ 0 : start ] + label )
return items
def RefreshSigns( self, file_name ): def RefreshSigns( self, file_name ):
if self._connection: if self._connection:
self._codeView.Refresh( file_name ) self._codeView.Refresh( file_name )