Variable explorer in interactive window debug session does not show locals #5626
Labels
bug
Issue identified by VS Code Team member as probable bug
interactive-window
Impacts interactive window
interactive-window-debugging
variable-explorer
The root cause of this is that when there is a local and global scope, e.g. we're stopped on a breakpoint inside a function in a Python module, two variables requests are sent from the client to the debug adapter. However it looks like our debug adapter tracker code assumes only one variables request is ever sent, and we overwrite
this.lastKnownVariables
for each response we process:vscode-jupyter/src/client/datascience/jupyter/debuggerVariables.ts
Lines 344 to 346 in 6cab79c
In the case where there is only a global scope, two variables requests are still sent (you can see this by setting a breakpoint in onDidSendMessage in debugLocationTracker.ts), but their contents are identical, which is why the variable explorer still shows the right variables. But when we're stopped in a function and the local scope variables response is processed before the global scope variables response, this results in the variable explorer failing to show local variables. E.g. in the screenshot below, the variable explorer only shows the globally declared
a
andb
, when it should also be showing the localdf
(which is shown in the locals window on the left):Instead I think we should combine the
allowedVariables
with the existingthis.lastKnownVariables
. We must also clearthis.lastKnownVariables
to avoid showing variables that have gone out of scope in the variable explorer, e.g. we can clear on a continue event (since we'll recompute the lastKnownVariables the next time we receive variables responses from the debug adapter).The text was updated successfully, but these errors were encountered: