diff --git a/ipykernel/debugger.py b/ipykernel/debugger.py index 44317764..1c9b9439 100644 --- a/ipykernel/debugger.py +++ b/ipykernel/debugger.py @@ -473,7 +473,15 @@ async def setBreakpoints(self, message): """Handle a set breakpoints message.""" source = message["arguments"]["source"]["path"] self.breakpoint_list[source] = message["arguments"]["breakpoints"] - return await self._forward_message(message) + message_response = await self._forward_message(message) + # debugpy can set breakpoints on different lines than the ones requested, + # so we want to record the breakpoints that were actually added + if "success" in message_response and message_response["success"]: + self.breakpoint_list[source] = [ + {"line": breakpoint["line"]} + for breakpoint in message_response["body"]["breakpoints"] + ] + return message_response async def source(self, message): """Handle a source message."""