Allow setting the value via the api

This commit is contained in:
Ben Jackson 2021-02-25 21:52:27 +00:00
commit 804b499286
4 changed files with 14 additions and 8 deletions

View file

@ -209,11 +209,15 @@ function! vimspector#ExpandVariable() abort
py3 _vimspector_session.ExpandVariable() py3 _vimspector_session.ExpandVariable()
endfunction endfunction
function! vimspector#SetVariableValue() abort function! vimspector#SetVariableValue( ... ) abort
if !s:Enabled() if !s:Enabled()
return return
endif endif
if a:0 == 0
py3 _vimspector_session.SetVariableValue() py3 _vimspector_session.SetVariableValue()
else
py3 _vimspector_session.SetVariableValue( new_value = vim.eval( 'a:1' ) )
endif
endfunction endfunction
function! vimspector#DeleteWatch() abort function! vimspector#DeleteWatch() abort

View file

@ -129,6 +129,7 @@ augroup VimspectorUserAutoCmds
autocmd user VimspectorDebugEnded silent autocmd user VimspectorDebugEnded silent
augroup END augroup END
" FIXME: Only register this _while_ debugging is active
augroup Vimspector augroup Vimspector
autocmd! autocmd!
autocmd BufNew * call vimspector#OnBufferCreated( expand( '<afile>' ) ) autocmd BufNew * call vimspector#OnBufferCreated( expand( '<afile>' ) )

View file

@ -526,8 +526,8 @@ class DebugSession( object ):
self._variablesView.ExpandVariable( buf, line_num ) self._variablesView.ExpandVariable( buf, line_num )
@IfConnected() @IfConnected()
def SetVariableValue( self, buf = None, line_num = None ): def SetVariableValue( self, new_value = None, buf = None, line_num = None ):
self._variablesView.SetVariableValue( buf, line_num ) self._variablesView.SetVariableValue( new_value, buf, line_num )
@IfConnected() @IfConnected()
def AddWatch( self, expression ): def AddWatch( self, expression ):

View file

@ -518,7 +518,7 @@ class VariablesView( object ):
}, },
} ) } )
def SetVariableValue( self, buf = None, line_num = None ): def SetVariableValue( self, new_value = None, buf = None, line_num = None ):
variable: Variable variable: Variable
view: View view: View
@ -532,6 +532,7 @@ class VariablesView( object ):
if not variable.IsContained(): if not variable.IsContained():
return return
if new_value is None:
new_value = utils.AskForInput( 'New Value: ', new_value = utils.AskForInput( 'New Value: ',
variable.variable.get( 'value', '' ), variable.variable.get( 'value', '' ),
completion = 'expr' ) completion = 'expr' )