Skip to content

Commit

Permalink
If signs are moved by user actions, use the current lnum of the sign …
Browse files Browse the repository at this point in the history
…for the breakpoint.
  • Loading branch information
puremourning committed Dec 14, 2019
1 parent 8d025c4 commit 16c3b65
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion python3/vimspector/breakpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def ListBreakpoints( self ):
else:
for file_name, breakpoints in self._line_breakpoints.items():
for bp in breakpoints:
self._SignToLine( file_name, bp )
qf.append( {
'filename': file_name,
'lnum': bp[ 'line' ],
Expand All @@ -113,6 +114,7 @@ def ClearBreakpoints( self ):
# These are the user-entered breakpoints.
for file_name, breakpoints in self._line_breakpoints.items():
for bp in breakpoints:
self._SignToLine( file_name, bp )
if 'sign_id' in bp:
vim.command( 'sign unplace {0} group=VimspectorBP'.format(
bp[ 'sign_id' ] ) )
Expand All @@ -132,6 +134,7 @@ def ToggleBreakpoint( self ):
found_bp = False
action = 'New'
for index, bp in enumerate( self._line_breakpoints[ file_name ] ):
self._SignToLine( file_name, bp )
if bp[ 'line' ] == line:
found_bp = True
if bp[ 'state' ] == 'ENABLED' and not self._connection:
Expand All @@ -143,7 +146,7 @@ def ToggleBreakpoint( self ):
bp[ 'sign_id' ] ) )
del self._line_breakpoints[ file_name ][ index ]
action = 'Delete'
break
break

self._logger.debug( "Toggle found bp at {}:{} ? {} ({})".format(
file_name,
Expand Down Expand Up @@ -215,6 +218,7 @@ def response_handler( source, msg ):
for file_name, line_breakpoints in self._line_breakpoints.items():
breakpoints = []
for bp in line_breakpoints:
self._SignToLine( file_name, bp )
if 'sign_id' in bp:
vim.command( 'sign unplace {0} group=VimspectorBP'.format(
bp[ 'sign_id' ] ) )
Expand Down Expand Up @@ -330,6 +334,7 @@ def _SetUpExceptionBreakpoints( self, configured_breakpoints ):
def _ShowBreakpoints( self ):
for file_name, line_breakpoints in self._line_breakpoints.items():
for bp in line_breakpoints:
self._SignToLine( file_name, bp )
if 'sign_id' in bp:
vim.command( 'sign unplace {0} group=VimspectorBP '.format(
bp[ 'sign_id' ] ) )
Expand All @@ -344,3 +349,17 @@ def _ShowBreakpoints( self ):
'vimspectorBP' if bp[ 'state' ] == 'ENABLED'
else 'vimspectorBPDisabled',
file_name ) )


def _SignToLine( self, file_name, bp ):
if 'sign_id' not in bp:
return bp[ 'line' ]

signs = vim.eval( "sign_getplaced( '{}', {} )".format(
utils.Escape( file_name ),
json.dumps( { 'id': file_name, 'group': 'VimspectorBP', } ) ) )

if len( signs ) == 1 and len( signs[ 0 ][ 'signs' ] ) == 1:
bp[ 'line' ] = int( signs[ 0 ][ 'signs' ][ 0 ][ 'lnum' ] )

return bp[ 'line' ]

0 comments on commit 16c3b65

Please sign in to comment.