tomblind / local-lua-debugger-vscode

Local Lua Debugger for VSCode
MIT License
107 stars 26 forks source link

Can't see debugger when path is not the workspace folder. #8

Closed Sheepolution closed 4 years ago

Sheepolution commented 5 years ago

I have my project set up in such way that my workspace has a folder game, and in that folder is my main.lua.

My launch.json looks like this:

{
    "configurations": [
      {
        "type": "lua-local",
        "request": "launch",
        "name": "Debug LÖVE",
        "program": {
          "command": "love"
        },
        "args": [
          "${workspaceFolder}/game"
        ]
      }
    ]
  }

When debugging, it does pause at the breakpoints, but it doesn't open the files and the line does not get highlighted.

tomblind commented 5 years ago

The issue here is that Love adds it's own custom loaders to require to resolve scripts in the game folder (see here). The debugger has no real way to detect this.

One workaround would be to set the current working directory to the game folder:

{
  "configurations": [
    {
      "type": "lua-local",
      "request": "launch",
      "name": "Debug LÖVE",
      "program": {
        "command": "love"
      },
      "args": [
        "${workspaceFolder}/game"
      ],
      "cwd": "${workspaceFolder}/game"
    }
  ]
}

Cases like this may warrant adding a new configuration option (scriptRoot or something), though.

Sheepolution commented 5 years ago

Thanks for the workaround, it works great!