Change default launch configuration from "${workspaceFolder}" to "${fileDirname}", for a better debugging experience with input files out of the box #7362
Labels
fixed
Check the Milestone for the release in which the fix is or will be available.
tasks/build/debug
An issue relating to tasks.json (e.g. build issues)
Projects
Milestone
Bug type: Debugger
System
OS and Version: Windows 20H2 (OS: Windows_NT x64 10.0.19042) with WSL Ubuntu G++ 9.3.0
VS Code Version: 1.55.2 (user setup)
Commit: 3c4e3df9e89829dce27b7b5c24508306b151f30d
Date: 2021-04-13T09:35:57.887Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
C/C++ Extension Version: 1.3.0
Other extensions you installed (and if the issue persists after disabling them): WSL extension, which is required for the above set up
A clear and concise description of what the bug is.
Currently the default launch.json file has a cwd value of:
${workspaceFolder}
. While this works fine a lot of the time, in some cases the debugger is unable to read variable values when taking input from files and if the file being debugged is not at the root of the workspace. This is due to it being launched at the root of the workspace and not at the location of the file being debugged. This can be rectified by changing the default launch location from${workspaceFolder}
to${fileDirname}
. Changing this should not have a large impact on most workflows as in most cases both the values will have the same result and if not, the file selected for debugging is likely the one that the developer is interested in.To Reproduce
Sample code
main.cpp
The code takes 2 numbers as input from a text file, then stores their product in a variable and outputs it
testin.txt
3 4
testout.txt
file should be empty
Original launch.json
Modified launch.json
Steps
As you can see, this is different from our expected values of 3, 4 and 12 respectively
cwd
value)The text was updated successfully, but these errors were encountered: