diff --git a/autoload/vimspector.vim b/autoload/vimspector.vim index 182a665..589439d 100644 --- a/autoload/vimspector.vim +++ b/autoload/vimspector.vim @@ -39,6 +39,10 @@ function! vimspector#ToggleBreakpoint() abort py3 _vimspector_session.ToggleBreakpoint() endfunction +function! vimspector#AddFunctionBreakpoint( function ) abort + py3 _vimspector_session.AddFunctionBreakpoint( vim.eval( 'a:function' ) ) +endfunction + function! vimspector#StepOver() abort py3 _vimspector_session.StepOver() endfunction diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 1acbc7b..77ab6ed 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -52,6 +52,7 @@ class DebugSession( object ): # - the split of responsibility between this object and the CodeView is # messy and ill-defined. self._line_breakpoints = defaultdict( list ) + self._func_breakpoints = [] self._configuration = None vim.command( 'sign define vimspectorBP text==> texthl=Error' ) @@ -87,11 +88,23 @@ class DebugSession( object ): # 'logMessage': ... } ) + self._UpdateUIBreakpoints() + + def _UpdateUIBreakpoints( self ): if self._connection: self._SendBreakpoints() else: self._ShowBreakpoints() + def AddFunctionBreakpoint( self, function ): + self._func_breakpoints.append( { + 'state': 'ENABLED', + 'function': function, + } ) + + # TODO: We don't really have aanything to update here, but if we're going to + # have a UI list of them we should update that at this point + self._UpdateUIBreakpoints() def Start( self, configuration = None ): self._configuration = None @@ -468,6 +481,19 @@ class DebugSession( object ): } ) + self._connection.DoRequest( + functools.partial( self._UpdateBreakpoints, None ), + { + 'command': 'setFunctionBreakpoints', + 'arguments': { + 'breakpoints': [ + { 'name': bp[ 'function' ] } + for bp in self._func_breakpoints if bp[ 'state' ] == 'ENABLED' + ], + } + } + ) + def _ShowBreakpoints( self ): for file_name, line_breakpoints in self._line_breakpoints.items(): for bp in line_breakpoints: