tomblind / local-lua-debugger-vscode

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

Feature request: Detect and highlight error from debug console #43

Closed Sheepolution closed 3 years ago

Sheepolution commented 3 years ago

I use Local Lua Debugger for running LÖVE, but I don't always require lldebugger, as that tends to slow down the game by a lot. I only do that when I actually want to debug something. However, one thing that's really nice about using the debugger is that when you get an error it will jump to that line and highlight it. I understand if it's not possible to do this without lldebugger, but the error also gets printed to the debug console. If possible, I would like Local Lua Debugger to read the contents of the debug console and interpret and highlight any error that appears in there.

If there is another solution to this, I would like to know. Perhaps with #20 the game doesn't run as slow and I can always be using lldebugger.

Sheepolution commented 3 years ago

I've played around with this some more. Like I said in the OP, I don't always require lldebugger because it slows down the game. However, it only slows down when you start the debugger. So what I can do is DEBUGGER = require "lldebugger" at the start, and then DEBUGGER.start() in love.errorhandler. Requiring lldebugger inside love.errorhandler doesn't work for whatever reason. It needs to be required beforehand.

This is what my love.errorhandler looks like:

function love.errorhandler(msg)
    msg = tostring(msg)
    error_printer(msg, 2)
    DEBUGGER.start()
    error(msg, 2)
end

If there is another solution to this, I would like to know

So for me, this is a satisfying alternate solution. If you want you may close this issue @tomblind.

tomblind commented 3 years ago

This would be a good optimization to get in, so I'll leave this issue open for that.