Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PSReadLine script hidden from debugger #3629

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Mar 21, 2023

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", and Ctrl+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. Then Ctrl+Break won't cause debugger to interrupt the script execution in PSReadLine.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

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

Oh, clever Dongbo!

@andyleejordan andyleejordan merged commit 8485855 into PowerShell:master Mar 21, 2023
@daxian-dbw daxian-dbw deleted the empty-queue branch March 21, 2023 20:39
@ghost
Copy link

ghost commented May 3, 2023

🎉 v2.3.1-beta1 has been released which incorporates this pull request. 🎉

andyleejordan added a commit to PowerShell/PowerShellEditorServices that referenced this pull request May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception thrown when stopping a stuck git log session with Alt+Pause
2 participants