Skip to content

Allow running/debugging a file in a workspace without adding an entry in launch.json #3710

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

Closed
2 tasks done
parched opened this issue Dec 2, 2021 · 3 comments · Fixed by #3772
Closed
2 tasks done
Labels
Area-UI Issue-Bug A bug to squash.

Comments

@parched
Copy link

parched commented Dec 2, 2021

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

I am new to using the powershell extension, but have previously used the python extension. The python extension adds an editor button to run or debug the current file, ignoring anything from launch.json. See the button from here.

I incorrectly assumed that when I pressed the similar looking button that the powershell extension provides on a ps1 file that it would just run that file. Instead, it runs the current configuration that I have selected in the debugger view (which happened to be some python thing completely unrelated to the powershell file open in the editor).

Proposed Design

My preference would be for the button to work like the python extension, although I imagine that would confuse people already used to be current behaviour. At the very least changing the tooltip from "Run" to something like "Run selected configuration" would have saved me some confusion.

@parched parched added the Issue-Enhancement A feature request (enhancement). label Dec 2, 2021
@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 2, 2021
@parched parched changed the title Allow running/debugging a file in a workspace without adding a entry in launch.json Allow running/debugging a file in a workspace without adding an entry in launch.json Dec 2, 2021
@JustinGrote
Copy link
Collaborator

JustinGrote commented Dec 2, 2021

@andschwa I don't think this is particularly unreasonable, it's pretty easy to "embed" a default launch configuration, we already do it via the pester "Run Tests" codelens.

@JustinGrote JustinGrote added Area-UI Up for Grabs Will shepherd PRs. and removed Needs: Triage Maintainer attention needed! labels Dec 2, 2021
@andyleejordan
Copy link
Member

Yup, I agree. This is something that bugs me too, would love to see it fixed. Not even sure if this is a feature request so much as a bug fix as I think it's an error that the extension just uses the current launch configuration. My guess is the vast majority of use cases for a PowerShell file would be (and are) the default "run this file" configuration.

@andyleejordan
Copy link
Member

It took a bit to figure out what exactly was going on here since I was making assumptions based on other erroneous behavior I was seeing. What we're actually looking to do in order to fix this is modify this command:

this.command6 = vscode.commands.registerCommand('PowerShell.Debug.Start',
async () => { await vscode.commands.executeCommand('workbench.action.debug.start'); })

So instead of calling workbench.action.debug.start (which leads to the bad behavior you're seeing where it just launches the selected configuration with no regard as to what it is) with a custom command that just runs the equivalent of a PowerShell: Launch Current File debug session.

@andyleejordan andyleejordan moved this from Todo to In Progress in Sea Biscuit Jan 22, 2022
@andyleejordan andyleejordan added Issue-Bug A bug to squash. and removed Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs. labels Jan 22, 2022
Repository owner moved this from In Progress to Done in Sea Biscuit Jan 24, 2022
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 a pull request may close this issue.

3 participants