PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
613 stars 207 forks source link

Fix debugging script blocks that aren't in files #2064

Closed andyleejordan closed 9 months ago

andyleejordan commented 10 months ago

The code relied on running list 1 <MaxInt> but that wasn't being run in the debug context because we allow-list commands to prevent pollution of the history, and missed it. Like the prompt and interactive commands (which list could be but is not when we run it) we need to check for this exact list command and run it under the debugger.

Moreover, we also weren't locking the debugInfoHandle, nor were we correctly checking if scriptListingLines was empty (it was never null), and our shortcut to skip allocation was broken. Actually we can't skip allocation, but we can at least skip superfluous conversions.

Resolves https://github.com/PowerShell/vscode-powershell/issues/3904.