microsoft / vscode-js-debug

A DAP-compatible JavaScript debugger. Used in VS Code, VS, + more
MIT License
1.67k stars 279 forks source link

Correctly display shadowed variables in hovers #2022

Closed connor4312 closed 3 months ago

connor4312 commented 3 months ago

With recent additions to DAP, evaluation requests can now come with a source and location. We should try to un-shadow variables in these evaluations so that the hovered variable is more consistent and reliable.

amunger commented 3 months ago

is the idea that something like this has accurate hover values?

const var1 = 1;

{
    const var1 = { str: 'value' };
    console.log(var1.str);
}

console.log(var1)

The only bit of inconsistency I notice is that when stopped on the second console.log, hovering the var1 within the scope has a value of 1, whereas hovering the first var1 while it's shadowed will display the type.