Debugger uses old cached (?) file and ignores breakpoints

Hi, I have a problem with the VS Code debugger. Unfortunately I have the same problem on 2 distinct PCs independently.

Whenever I run the debugger, then program ends and then change some of my julia code, it breaks the debugger and its unusable until IDE restart. (it doesnt break always). Its pretty uncomfortable, e…g when a regular julia error appears in terminal and I click the stacktrace line, VS Code shows me wrong line.

Also (I believe it is a symptom of the same underlying problem) when I run some code, then change it and then use a breakpoint and then start debugger again, the code stops at the breakpoint (I can use debug console to see variable’s state) but using “Step Into” or “Step over” or “Continue” buttons does effectively nothing, it just flashes.

What could be the cause and the solution? I can’t even word it properly for google.

Using Revise should fix that…it should work hand-in-hand with the debugger to report updated line numbers. If not, can you give a concrete example?

I was not using Revise. I had a feeling that this was not the problem because the running code was correct (based on results) but the IDE reaction to it was incorrect, but maybe I mis-identified it, thanks. Will try Revise and see if the problem disappears.

As best I understand, VSCode includes Revise in its back end, and theoretically it shouldn’t be necessary for you to explicitly use it. So indeed you may have something else going on; the desynchronization between “what it does” and “what you see” seems surprising to me. But I am not the expert on how VSCode interacts with JuliaInterpreter.

The problem seems to be the scope? I’m sure you know about it I just didn’t occur to me to mention it but the problem is that if the code is in a file in global scope (not inside any function), then the behavior described above takes place (I’m unable to debug).
As soon as the code is inside any function (and that function is being called) then the debugger will work as expected.