Rudimentary support for listing breakpoints using the quickfix window

This commit is contained in:
Ben Jackson 2019-02-12 22:41:10 +00:00
commit 3092c06cd7
3 changed files with 53 additions and 0 deletions

View file

@ -102,6 +102,10 @@ function! vimspector#ShowOutput( category ) abort
py3 _vimspector_session.ShowOutput( vim.eval( 'a:category' ) )
endfunction
function! vimspector#ListBreakpoints() abort
py3 _vimspector_session.ListBreakpoints()
endfunction
" Boilerplate {{{
let &cpo=s:save_cpo
unlet s:save_cpo

View file

@ -168,6 +168,22 @@ class CodeView( object ):
file_name ) )
def BreakpointsAsQuickFix( self ):
qf = []
for file_name, breakpoints in self._breakpoints.items():
for breakpoint in breakpoints:
qf.append( {
'filename': file_name,
'lnum': breakpoint.get( 'line', 1 ),
'col': 1,
'type': 'L',
'valid': 1 if breakpoint.get( 'verified' ) else 0,
'text': "Line breakpoint - {}".format(
'VERIFIED' if breakpoint.get( 'verified' ) else 'INVALID' )
} )
return qf
def LaunchTerminal( self, params ):
# kind = params.get( 'kind', 'integrated' )

View file

@ -66,6 +66,39 @@ class DebugSession( object ):
self._init_complete = False
self._launch_complete = False
def ListBreakpoints( self ):
# FIXME: Handling of breakpoints is a mess, split between _codeView and this
# object. This makes no sense and should be centralised so that we don't
# have this duplication and bug factory.
qf = []
if self._connection and self._codeView:
qf = self._codeView.BreakpointsAsQuickFix()
else:
for file_name, breakpoints in self._line_breakpoints.items():
for bp in breakpoints:
qf.append( {
'filename': file_name,
'lnum': bp[ 'line' ],
'col': 1,
'type': 'L',
'valid': 1 if bp[ 'state' ] == 'ENABLED' else 0,
'text': "Line breakpoint - {}".format(
bp[ 'state' ] )
} )
# I think this shows that the qf list is not right for this.
for bp in self._func_breakpoints:
qf.append( {
'filename': '',
'lnum': 1,
'col': 1,
'type': 'F',
'valid': 1,
'text': "Function breakpoint: {}".format( bp[ 'function' ] ),
} )
vim.eval( 'setqflist( {} )'.format( json.dumps( qf ) ) )
def ToggleBreakpoint( self ):
line, column = vim.current.window.cursor
file_name = vim.current.buffer.name