Open rewqazxv opened 2 years ago
@rewqazxv within the launch.json the following structure has worked for me:
"program": {
"lua": "lua5.3",
"file": "${workspaceFolder}/test/main.lua",
},
Perhaps worth trying?
@s6mike it works, but the problem is that the file path cannot contain ..
I put a realpath
command in the path field to solve it:
"program": {
"lua": "lua",
"file": "`realpath ../test/main.lua`",
},
I found the getAbsolute
function in debugger/path.ts
to be too simplistic for Windows paths, which could be a potential problem.
For example:
X:file
is expected to X:\path\to\file
, but getAbsolute
gives ${PWD}\X:file
\path\to\file
is expected to X:\path\to\file
, but getAbsolute
thinks it is a full absolute pathRef: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
@rewqazxv: Thanks for the hints and the code in your #71 pull request. However it did not fully fix it for me (under Windows). It seems like #57 (file name case) is also relevant, so I changed the comparePaths(a,b)
function in lldebugger.lua to make the compare lowercase:
local function comparePaths(a, b)
return Path.getAbsolute(a):lower() == Path.getAbsolute(b):lower();
end
For Windows, the Path.getCwd()
function did not work for me (popen seems to be missing, I am using a custom lua build), so I replaced it using lfs.currentdir()
as follows:
function Path.getCwd()
if not cwd then
local lfs = require('lfs')
cwd = lfs.currentdir()
end
return cwd
end
As I have no idea on how to do my own local-lua-debugger build, I've simply changed the code shown above directly in the VSCode extension folder location at %USERPROFILE%\.vscode\extensions\tomblind.local-lua-debugger-vscode-0.3.3\debugger\lldebugger.lua
(knowing my changes will likely get overwritten with the next extension update). Anyway, maybe it helps others using this very nice extension (a big thank you to @tomblind) on Windows.
Final note: The issue (missed breakpoints) did not occur consistently between multiple machines (same project/file/folder structure, on some machines it worked on others not). After applying the fixes, it worked for all machines (however, as I've also cleaned up the VSCode workspace folder (as suggested in #55), I am not a 100% sure, if the lldebugger.lua
changes described above fix all cases or if a cleanup of the VSCode workspace is additionally needed).
Example file structure:
All breakpoints work when I set program.file to
./main.lua
, but when I change program.file to../test/main.lua
, the lua interpreter runs to the end without breaking.My environments: vscode version 1.68.0, local lua debugger version 0.3.3