Conversation

andyleejordan

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 PowerShell/vscode-powershell#3904.

@andyleejordanandyleejordan requested a review from a team September 8, 2023 20:02
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.
@andyleejordanandyleejordan force-pushed the andyleejordan/fixScriptBlockDebugging branch from b126eda to a218596 Compare September 8, 2023 22:49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andyleejordanandyleejordan added this pull request to the merge queue Sep 12, 2023
Merged via the queue into main with commit 0fcb641 Sep 12, 2023
@andyleejordanandyleejordan deleted the andyleejordan/fixScriptBlockDebugging branch September 12, 2023 16:50
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Area-Debugging Issue-BugA bug to squash.
Status: Done

Successfully merging this pull request may close these issues.

Not in file Scriptblock debugging create empty temporary file