PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explicit String Variables (e.g. ${variable}) do not resolve in debugging

JustinGrote opened this issue · comments

Type: Bug

$module = 'test'
"${module}"

Start Debugging.

Expected: Can peek the value during debugging
Actual: Cannot, however "$module" works fine.
image

Extension version: 2023.11.1
VS Code version: Code 1.85.1 (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.22635
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 6800U with Radeon Graphics (16 x 2695)
GPU Status 2d_canvas: enabled
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.19GB (1.14GB free)
Process Argv --folder-uri file:///d%3A/ModuleFast --crash-reporter-id 99191045-cf32-42d4-8db5-3d79cfdaed76
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
vsjup518:30340749
vshan820:30294714
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
py29gd2263:30899288
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
azure-dev_surveyone:30548225
89544117:30613380
2i9eh265:30646982
0bi6i642:30917235
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30902429
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
aa_t_chat:30882232
cp7184t3:30927821

Ok so the good news is that we know how to do this correctly, since watch expressions are evaluated as intended:
image

Debugging it reveals that hovering over "${module}" is processed by the hover handler (which just gets the symbol details and returns that it's a variable with the name module) and hovering over "$module" actually goes through the code lens handler.

To be continued...

I think what's going on is that, while debugging, VS Code automatically looks up the values of symbols on hover if they are variables. So $module is recognized as a variable because of its symbol type, but ${module} is not (it's an expression). I actually plumbed in logic to evaluate variables on hover and it works like you'd expect (though I haven't fixed up the formatting).

image

So like when I have all LSP messages getting logged, when not debugging I see a hover request go across for both ${module} and $module, but when debugging I only see a hover request go across for ${module}, there is no request being sent for $module which is what makes me think VS Code is doing a client-side lookup for the variable's value based on the already known list of variables and their values (since the debugger is stopped).