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

launchDirectory is incorrect in multi-root workspace #159

Open
bersbersbers opened this issue Feb 23, 2022 · 3 comments
Open

launchDirectory is incorrect in multi-root workspace #159

bersbersbers opened this issue Feb 23, 2022 · 3 comments

Comments

@bersbersbers
Copy link

bersbersbers commented Feb 23, 2022

Describe the bug
In a multi-root workspace, the launch directory is incorrect. I think this is two issues at once:

  1. 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.)
  2. It is overwritten with an incorrect value. This is due to
    rStartupArguments.cwd ||= vscode.workspace.workspaceFolders?.[0].uri.fsPath;

    (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
@renkun-ken
Copy link
Contributor

@bersbersbers
Copy link
Author

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.

@renkun-ken
Copy link
Contributor

Yes, it should be adjusted for the purpose of debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants