local-lua-debugger-vscode
local-lua-debugger-vscode copied to clipboard
Source mapping doesn't work with multiple sources in one map
The source mapping feature works well when each lua file has its own .lua.map file. However, when using the luaBundle feature of TypeScriptToLua or other tools that generate a single lua file with one .lua.map which points to many source files, the debugger seems to get breakpoints across different files mixed up, and often skips them. For example, if you have a breakpoint in a file like foo.ts in the love-ts test, but no breakpoint in main.ts, then the debugger will ignore the breakpoint in foo.ts and never break.
This is fixed in my fork by changing the conditional in Breakpoint.add from
if (mapping.sourceLine === line) {
sourceFile = file;
file = scriptFile;
sourceLine = line;
line = scriptLine;
break;
}
to
if (mapping.sourceLine === line && file === sourceMap.sources[mapping.sourceIndex]) {
sourceFile = file;
file = scriptFile;
sourceLine = line;
line = scriptLine;
break;
}