From 9d9c2214f39ff62bc4769c76f0101c8fb23716d6 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 26 May 2018 19:08:59 +0100 Subject: [PATCH] Breakpoints returned from servers rarely have source set For line-breakpoints we already know it, so just use what we said originally. For method breakpoints, we have no clue. While some servers return a line, it could be in any file, so we just ignore them. --- python3/vimspector/code.py | 16 ++++++++-------- python3/vimspector/debug_session.py | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/python3/vimspector/code.py b/python3/vimspector/code.py index 7537d56..c290fe3 100644 --- a/python3/vimspector/code.py +++ b/python3/vimspector/code.py @@ -85,17 +85,17 @@ class CodeView( object ): self._signs[ 'vimspectorPC' ] = None - def AddBreakpoints( self, breakpoints ): + def AddBreakpoints( self, source, breakpoints ): for breakpoint in breakpoints: - if not breakpoint.get( 'verified', False ): - continue - if 'source' not in breakpoint: - self._logger.warn( 'source not in breakpoint {0}'.format( - json.dumps( breakpoint ) ) ) - continue + if source: + breakpoint[ 'source' ] = source + else: + self._logger.warn( 'missing source in breakpoint {0}'.format( + json.dumps( breakpoint ) ) ) + continue - self._breakpoints[ breakpoint[ 'source' ][ 'file' ] ].append( + self._breakpoints[ breakpoint[ 'source' ][ 'path' ] ].append( breakpoint ) self._logger.debug( 'Breakpoints at this point: {0}'.format( diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 9f3dd6c..15afcd7 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -17,6 +17,7 @@ import logging import vim import json import os +import functools from collections import defaultdict @@ -213,8 +214,8 @@ class DebugSession( object ): 'arguments': self._configuration[ 'configuration' ] } ) - def _UpdateBreakpoints( self, message ): - self._codeView.AddBreakpoints( message[ 'body' ][ 'breakpoints' ] ) + def _UpdateBreakpoints( self, source, message ): + self._codeView.AddBreakpoints( source, message[ 'body' ][ 'breakpoints' ] ) self._codeView.ShowBreakpoints() def OnEvent_initialized( self, message ): @@ -222,15 +223,16 @@ class DebugSession( object ): for file_name, line_breakpoints in self._breakpoints.items(): breakpoints = [ { 'line': line } for line in line_breakpoints.keys() ] + source = { + 'name': os.path.basename( file_name ), + 'path': file_name, + } self._connection.DoRequest( - self._UpdateBreakpoints, + functools.partial( self._UpdateBreakpoints, source ), { 'command': 'setBreakpoints', 'arguments': { - 'source': { - 'name': os.path.basename( file_name ), - 'path': file_name, - }, + 'source': source, 'breakpoints': breakpoints, 'lines': [ line for line in line_breakpoints.keys() ], 'sourceModified': False, @@ -239,7 +241,7 @@ class DebugSession( object ): ) self._connection.DoRequest( - self._UpdateBreakpoints, + functools.partial( self._UpdateBreakpoints, None ), { 'command': 'setFunctionBreakpoints', 'arguments': {