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

Using a launch configuration with interactive arguments does not work correctly in Powershell preview extension #3770

Closed
5 tasks done
Hetshu opened this issue Jan 18, 2022 · 4 comments · Fixed by PowerShell/PowerShellEditorServices#1702
Assignees
Labels
Area-Debugging Bug: Pre-release Bugs reproducing only in the pre-release extension. Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@Hetshu
Copy link

Hetshu commented Jan 18, 2022

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

Using a launch configuration like

{
            "name": "Current File w/Args",
            "type": "PowerShell",
            "request": "launch",
            "script": "${file}",
            "args": [
                "${command:SpecifyScriptArgs}"
            ],
            "cwd": "${file}"
},

and starting the debugger in a powershell script tab with F5 and adding the following arguments in the following popup
image

results in the following terminal output
image
if running this with Powershell Preview extension.

This prevents the powershell script to parse the supplied parameters correctly.

Erroneous behavior:

image

Expected behavior: (screenshot from working non preview powershell extension)

image

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.63.2
899d46d82c4c95423fb7e10e68eba52050e30ba3
x64

Extension Version

ms-vscode.powershell-preview@2022.1.0

Steps to Reproduce

see above in the summary

Visuals

No response

Logs

No response

@Hetshu Hetshu added the Issue-Bug A bug to squash. label Jan 18, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jan 18, 2022
@andyleejordan
Copy link
Member

Thanks for getting this filed @Hetshu!

@andyleejordan andyleejordan added Area-Debugging Bug: Pre-release Bugs reproducing only in the pre-release extension. and removed Needs: Triage Maintainer attention needed! labels Jan 18, 2022
@andyleejordan andyleejordan added this to the Committed-vNext milestone Jan 18, 2022
@andyleejordan andyleejordan self-assigned this Feb 3, 2022
@andyleejordan
Copy link
Member

So I dug into this a bit and...my conclusion is that we can't support multiple arguments via specifyScriptArgs any more because of an upstream VS Code change in 2018. The command can only return a string, which means that when specified in launch.json as "args": ["{command:specifyScriptArgs"] we only ever get a single-element array, e.g. ["every, thing; you specified, here"]. This "bug" manifested because we're now correctly escaping arguments given in the args array, so no matter what you input in the prompt box, a single string element is given to the debugger. This is the given API from VS Code. @SeeminglyScience @JustinGrote @SydneyhSmith @StevenBucher98 I propose we deprecate specifyScriptArgs as this behavior is confusing and not supported by the editor itself. We could have specifyScriptArg (note, not plural) but is there any real value in that?

@andyleejordan
Copy link
Member

After reviewing the existing examples, while we think we should document that the expect usage is ["an", "array", "of", "string", "args"] (which is the schema for launch.json and is what e.g. the Python extension documents) we're going to revert the change made last November to "helpfully" add quotes around arguments with spaces in them. This will allow a ["string space separated string with multiple args"] to work because we'll be passing the user's raw arguments, but we're also going to change the documentation because that's not the right way to do it (but will enable specifyScriptArgs to keep working).

@andyleejordan
Copy link
Member

Fixed via PowerShell/PowerShellEditorServices#1702.

@andyleejordan andyleejordan added the Resolution-Fixed Will close automatically. label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Bug: Pre-release Bugs reproducing only in the pre-release extension. Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
No open projects
Status: Done
2 participants