Make PSReadLine script hidden from debugger #3629
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Fix #3260
PowerShell has a handler for
Ctrl+Break
, to break into debugger on the currently running script. This makes it possible to cause debugger to stop on the script that PSReadLine is running internally while it's idle (not processing any input keys). For example, it may be triggering the pulse pipeline for event processing by running the script"0"
, andCtrl+Break
causes the debugger to break in the script and pause the execution.When this happens, a nested prompt will be provided to the user, which calls PSReadLine again to process input, which causes the re-entry of PSReadLine and make it crash.
The fix is to make the internal PSReadLine script hidden from PowerShell debugger, just like the built-in functions in PowerShell, such as
prompt
. ThenCtrl+Break
won't cause debugger to interrupt the script execution in PSReadLine.PR Checklist
Microsoft Reviewers: Open in CodeFlow