Debugger out-of-sync with code with blank line #16407
Labels
bug
Issue identified by VS Code Team member as probable bug
notebook-debugging
triage-needed
Issue needs to be triaged
Milestone
Type: Bug
The debugger seems to be thrown off by a blank line at the start of a code cell, resulting in an "off by one" of breakpoints and the yellow "current statement" indicator.
To see this, create a new notebook and choose the Python kernel. Create two cells.
Cell 1. Important: there is a blank line before the
def
statement.Cell 2:
fib(.)
.raise
statement without stopping at theif
statement. Note that the argument is 5, so we're not actually on theraise
line, we are actually on theif n < 0
line.return n
line, without hitting the secondif
statement. However, actually, the intperter is on theif
statement: the UI is wrong.raise
. What actually happened is that the debugger is executing thereturn...
line, which calls the method recursively. However, the visual indicator did not show this was happening.Screen shot when hitting the first breakpoint:
As you can see, when the UI indicator is out of sync with the code, it is very hard to follow what is going on.
The workaround is to remove the blank line:
def
in cell 1 and execute the cell.A simple explanation is that, in the first case, the code is out of sync with the interpreter: that we forgot to excute the cell to save our changes. This is easy to verify: just add the blank line back and choose Debug Cell. The debugger does not stop because the byte codes are out of sync with the source.
With the blank line added back, save the cell. Debug again. The debugger is again out of sync. This shows that the problem is not user error, but rather an actual repeatable bug.
Finally, note that the problem does not occur if the blank line is replaced by a comment:
This problem may be new: I don't recall seeing it in previous versions over the last year, but it could be that I never had a blank line above my code previously.
Extension version: 2024.11.0
VS Code version: Code 1.96.4 (cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba, 2025-01-16T00:16:19.038Z)
OS version: Linux x64 6.8.0-51-generic
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: