Description
I originally filed this against the cpptools extension but they suggested I file it here.
Consider the case where you are filling out the parameters for a particular language extension to launch your target in a debugger. You need a way to specify command line arguments to the target. Since everything is done via JSON, the natural way to represent this is by having the arguments be in a JSON array. This provides benefits such as being able to have arguments that contain spaces, which would be very difficult / impossible to acheive if your configuration just had a single variable like targetargs: "<arg string>"
.
But this presents some issues of its own. Specifically, a very common workflow, which is shared by almost all languages and debugging scenarios is that you have already tried running a command locally, and it failed, so you then want to copy the command line you ran it with over to the debugger. In something like MSVC, or even command line tools like GDB, this is easy. You just paste your command line and go.
In VSCode, this is extremely cumbersome because you have to convert it to a JSON array. If it's a simple command line, like foo.exe arg1 arg2 arg3 arg4
then this means you have to add quotes and commas everywhere, and then ideally you even have to format the new json array to not look terrible and to be easily readable. So you'll end up doing something like this:
"launch_args": [
arg1 arg2 arg3 arg4 # This comes from pushing Ctrl+V
]
and then fixing it up manually to look like this:
"launch_args": [
"arg1",
"arg2",
"arg3",
"arg4"
]
It's not hard to imagine a tool invocation where there are 20-30+ command line arguments (see the aforementioned link on the cpptools github for a specific one), and for which this starts to become a serious usability nightmare.
One solution is to simply provide a keybinding, like Ctrl+Shift+V, or Ctrl+V+V, or something else you make up, that will just automatically do this for you. It should be able to handle quotes and spaces appropriately, so that if my clipboard contains something like "foo bar" "baz" bu\"zz
, it would paste
"foo bar",
"baz",
"bu\"zz"
Additionally, it could automatically format the json array upon pasting so that the indentation matches with the scope of the array that you're pasting into.
I think this would be an extremely useful quality of life feature, not just for cpptools, but for any language extension that allows you to specify a command line when debugging.