scalameta / metals-feature-requests

Issue tracker for Metals feature requests
37 stars 4 forks source link

Worksheet REPL mode #324

Open leonbur opened 1 year ago

leonbur commented 1 year ago

Is your feature request related to a problem? Please describe.

When I use a worksheet, I expect it to only execute what I'm adding and not reevaluate the whole file. In IntelliJ this is the default for worksheets and it's called REPL Mode.

Describe the solution you'd like

Have a mode switch between Plain and REPL modes for worksheet. making REPL mode the default will help migrators from IntelliJ.

Describe alternatives you've considered

comparatively, only IntelliJ does this and IMHO it's best way to program instead of restarting every time. Ammonite is good but it's not a full blown IDE with syntax highlighting and everything.

Additional context

No response

Search terms

worksheet repl

tgodzik commented 1 year ago

Thanks for the suggestion! Currently, worksheet always evaluate the entire file since they don't use the REPL underneath, we would need to reimplement the worksheet feature with REPL to support it.

I wonder what are the advantages over just using REPL? Does it always evaluate the changed line and all below it?

leonbur commented 1 year ago

I wonder what are the advantages over just using REPL?

The advantages over just a REPL is that you can edit your code in a normal manner with syntax highlighting and completion. Not leaving the environment to test something is great. also if some code is ready, you can use the worksheet to try some tests on it and then copy whatever works straight to the test file.

Does it always evaluate the changed line and all below it?

Yes.

A more advanced feature would be to have a shortcut to only evaluate a "code block" where you can highlight a closure (such as a function) among the various things in the file and with the shortcut it will be sent to the underlying REPL (pretty much like in Clojure REPLs)

tgodzik commented 1 year ago

Thanks for the explanation! I must admit that we don't have enough time to work on it in the near future, but if anyone is willing I can try to help out.