Skip to content

Fix PowerShell.Debug.Start to just launch current file #3772

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

Merged
merged 4 commits into from
Jan 24, 2022

Conversation

andyleejordan
Copy link
Member

@andyleejordan andyleejordan commented Jan 19, 2022

This command previously used a private API
workbench.action.debug.start which led to bad behavior. Namely it
meant that while a PowerShell file was opened, if the triangular "Start"
button was pressed, it would start Code's currently selected launch
configuration which is often not what the user intended.

  1. If there was no launch.json this worked accidentally in that we
    resolved a default configuration to launch the current file.
  2. If a working PowerShell configuration was selected, it may work as
    intended, unless that configuration was to attach.
  3. If any other configuration was selected, the user would be left
    bewildered as to why, say, a Python debugger was started for a
    PowerShell file.

Instead we call the public API to start the debugger and give it a copy
of our "Launch Current File" configuration, which is what the user
intended do when clicking the "Start" button on a PowerShell file.

This may introduce some breaking behavior if the user was relying on
this button to start their current correctly configured (and selected)
launch configuration with possible extra customizations. However, in
that the case the user can use Code's built-in options to call the
private API we were calling preivously, namely F5 or the triangular
start button in the debugger workbench (instead of our button).

Fixes #3710, cleans up some files, and reverts a bug introduced in #3518.

This command previously used a private API
`workbench.action.debug.start` which led to bad behavior. Namely it
meant that while a PowerShell file was opened, if the triangular "Start"
button was pressed, it would start Code's currently selected launch
configuration which is often not what the user intended.

1. If there was no `launch.json` this worked accidentally in that we
   resolved a default configuration to launch the current file.
2. If a working PowerShell configuration was selected, it may work as
   intended, unless that configuration was to attach.
3. If any other configuration was selected, the user would be left
   bewildered as to why, say, a Python debugger was started for a
   PowerShell file.

Instead we call the public API to start the debugger and give it a copy
of our "Launch Current File" configuration, which is what the user
intended do when clicking the "Start" button on a PowerShell file.

This may introduce some breaking behavior if the user was relying on
this button to start their current correctly configured (and selected)
launch configuration with possible extra customizations. However, in
that the case the user can use Code's built-in options to call the
private API we were calling preivously, namely F5 or the triangular
start button in the debugger workbench (instead of our button).
@ghost ghost added Area-UI Issue-Enhancement A feature request (enhancement). labels Jan 22, 2022
@andyleejordan andyleejordan changed the title WIP: Improve debug configurations Fix PowerShell.Debug.Start to just launch current file Jan 22, 2022
@andyleejordan
Copy link
Member Author

See microsoft/vscode#59689 for rationale as to why we shouldn't have been calling the formerly used API.

@andyleejordan andyleejordan added Issue-Bug A bug to squash. and removed Issue-Enhancement A feature request (enhancement). labels Jan 22, 2022
@andyleejordan andyleejordan marked this pull request as ready for review January 22, 2022 00:20
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM!

@andyleejordan andyleejordan merged commit 37f1f30 into master Jan 24, 2022
@andyleejordan andyleejordan deleted the andschwa/debug-config branch January 24, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UI Issue-Bug A bug to squash.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow running/debugging a file in a workspace without adding an entry in launch.json
2 participants