microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.42k stars 1.52k forks source link

Support 'argsCanBeInterpretedByShell' property as part of DAP #10654

Open ansonmiu0214 opened 1 year ago

ansonmiu0214 commented 1 year ago

Feature Request

Can we support the "argsCanBeInterpretedByShell" property in the RunInTerminalRequest as part of the Debug Adapter Protocol? Official release notes - https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_70.md#argscanbeinterpretedbyshell-for-runinterminalrequest

This feature is supported by the VS Code Node debugger.

This will allow us to supply unmodified argument strings to the underlying C++ program when debugging. A use-case for this feature is to support prompting the user for command line arguments to pass to the underlying C++ program using VS Code's promptString variable substitution:

// launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug with Args",
            "type": "cppdbg",
            "request": "launch",
            // Resolved by CMake Tools:
            "program": "${command:cmake.launchTargetPath}",
            "args": "${input:commandLineArgs}",
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    // add the directory where our target was built to the PATHs
                    // it gets resolved by CMake Tools:
                    "name": "PATH",
                    "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
                },
            ],
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
        }
    ],
    "inputs": [
        {
            "type": "promptString",
            "id": "commandLineArgs",
            "description": "Args to pass to executable",
            "default": ""
        }
    ]
}

This launch.json file currently fails with a parse error:

Unable to start debugging. Error converting value "epex epex" to type 'System.Collections.Generic.List`1[System.String]'. Path 'args', line 1, position 121.
roblourens commented 3 months ago

Would also like to see this, as I went to clean up the old workaround that we have (an arg of exactly ">" or "<" will not be escaped) but see that C++ hasn't adopted it.

Full context is in https://github.com/microsoft/debug-adapter-protocol/issues/146 and https://github.com/microsoft/vscode/issues/148887