Modifying debugger to return the same breakpoints in 'debugInfo' response as 'setBreakpoints' #1140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, I make changes to
debugger.pyso that the breakpoints returned in adebugInforesponse match the breakpoints returned in the most recentsetBreakpointsrequest.Bug context:
When a user clicks on a gutter to add/remove a breakpoint, a setBreakpoints request is sent. The UI changes according to the response of the setBreakpoints request, which gives a list of the breakpoints that were actually added. debugInfo is used to populate the UI breakpoints when a notebook is refreshed. So, it is important that the debugInfo and setBreakpoints information aligns.
Let's say we try to add a breakpoint at a commented out line (say line 2).
debugpywill infer that that line is not a runnable piece of code, so it will add a breakpoint to the line of code before that (say line 1), and thesetBreakpointsresponse will consist of a breakpoint at line 1. However, thedebugInforequest is implemented byipykernel, and the list of breakpoints for that is maintained by just recording the breakpoints that were sent in the setBreakpoints request. So, adebugInforequest would contain the information that there is a breakpoint at line 2. This causes confusing jumping behavior when thedebugInforequest gets called, like on refresh.In the video, the breakpoint jumps from line 1 to line 2 when the page is refreshed. Then, if I try to add a breakpoint at line 1, the breakpoint at line 2 disappears (because the
setBreakpointsresponse contains the correct info, which is that there is no breakpoint at line 2).inconsistent-breakpoints.mov
Fix:
I fix this by modifying the
setBreakpointsrequest handler indebugger.pyto record the response of thesetBreakpointsrequest as the information for the debugInfo request.