Open harpocrates opened 2 months ago
Thanks for reporting! I think we can make it work after https://github.com/scalameta/metals/pull/7006 as otherwise run would become much slower.
Ach, actually I misread, since this also happens in debug mode. The issue is that we compile things in the background.
Copying everything might introduce additional delay, so not sure if we want to do it right now. Will move it to feature requests for now
Could we at least introduce a flag around this?
I have users who are hitting an annoying variation of this (happy to open a separate issue for the other as well): they click on the code lens before compilation has finished (or worse - when compilation is failing due to errors) and the lens silently runs old code.
The flag I'm thinking of would enable a slower but more correct code lens:
Sure, we could add something like:
compilation failed, do you want to run the old code?
That would make the users aware of the issue.
As for copying the problem I don't think that's really solvable, at least that way. For large projects we would need to copy every module we depend on, which would be a huge amount of copying. It would also need to be done in Bloop, metals and any other bsp server. I need to think about how to do that properly and in a way that's maintainable.
Describe the bug
I was a bit surprised to learn that running through both launch configurations and code lens may be running code that was compiled after the run was kicked off.
Repro
Take this code:
Main
. Terminal should open withwaiting until enter...
, but don't hit enter yet!def four = 4
todef four = 5
Helper.four = 5
in the terminal outputSame occurs with a launch config, though passing
"jvmOptions": ["-verbose:class"],
there makes the problem apparent. Here's the terminal output (repeating above steps but with step 2 being "Run > Run Without Debugging"):Helper
doesn't get loaded in until after we hit enter, and it is loaded straight from where bloop compiled it.Expected behavior
I'd expect that running takes a defensive copy or the classfiles being run (or at least there's a setting to recover that behavior) at the time that I click the code lens or launch the run config.
Operating system
macOS
Editor/Extension
VS Code
Version of Metals
v1.4.2
Extra context or search terms
No response