`launchDirectory` is incorrect in multi-root workspace
Describe the bug In a multi-root workspace, the launch directory is incorrect. I think this is two issues at once:
- The value set in the launch config is overwritten. (I am not sure why that is, but I also checked hard-coded literals in the debug config, and they never become effective.)
- It is overwritten with an incorrect value. This is due to
https://github.com/ManuelHentschel/VSCode-R-Debugger/blob/075bee30fc46137335f29ff21992710549a69446/src/debugRuntime.ts#L112
(I feel it should be overwritten with the file's workspace folder,
workspace.getWorkspaceFolder(uri), see https://github.com/microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs#eliminating-rootpath)
To Reproduce
D:\>tree /f R
Folder PATH listing for volume Data
D:\R
│ R.code-workspace
│
├───R1
│ .Rprofile
│
└───R2
│ .Rprofile
│ code.R
│
└───.vscode
launch.json
tasks.json
D:\>more R\R.code-workspace
{
"folders": [
{
"path": "R1"
},
{
"path": "R2"
}
]
}
D:\>more R\R1\.Rprofile
i_am <- "R1"
D:\>more R\R2\.Rprofile
i_am <- "R2"
D:\>more R\R2\code.R
print(i_am)
D:\>more R\R2\.vscode\launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "R-Debugger",
"name": "Debug R-File",
"request": "launch",
"debugMode": "file",
"launchDirectory": "${workspaceFolder}",
"workingDirectory": "${workspaceFolder}",
"file": "${file}",
}
]
}
D:\>more R\R2\.vscode\tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "show $workspaceFolder",
"type": "shell",
"command": "echo ${workspaceFolder}",
"problemMatcher": []
}
]
}
code R\R.code-workspace R\R2\code.R
Then start debugging using "Debug R-File (R2)".
Expected behavior "R2" in the Debug Console
Actual behavior "R1" in the Debug Console
In the output, one can see
[info....] [10:04:30.630] [ ] R Startup:
[info....] [10:04:30.630] [ ] {"path":"\"C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe\"","args":["--quiet","--no-save","--ess"],"cwd":"d:\\R\\R1"}
Desktop (please complete the following information):
- OS: Windows and Linux
- R Version: 4.1.2
- vscDebugger Version: 0.4.7
- vscode-r-debugger Version: v0.4.7
Maybe https://github.com/REditorSupport/vscode-R/blob/master/src/util.ts#L149 could be useful?
I guess so, yes. I just wonder if vscode.window.activeTextEditor is a good choice - the debug launch config does does not necessarily have anything to do with the currently open file.
Yes, it should be adjusted for the purpose of debugging.