Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
202 stars 28 forks source link

Save active file on repl run #45

Closed shocoman closed 2 years ago

shocoman commented 3 years ago

I probably should post it as separate PRs, but all these "features" are too questionable to me I) Save a file when user presses "Run file in terminal" or "Load file in REPL" Why? Merely for consistency. "Execute selection in REPL" works with a current "visible" selection, while aforementioned options work with some "background" text (if text was edited). Here is simple example of that ut39SOP7ix Yes, I am aware of "File/Auto Save", but that actually makes it even worse as due to "save delay" sometimes it saves file before i press "run", and sometimes it doesn't

II) and here is my favourite hackiest solution of all time. As described in corresponding issue (#40) REPL simply ignores passed commands if it wasn't already working. I presume we need to wait some time for Racket REPL to actually start. On my PC it takes about 450-550 ms. So the best I could do is to use setTimeout to wait for 1 second 😺 . Well, at least it doesn't make things worse. The alternative would be to pass code to Racket on start with something like "racket -i -e (...)", but I presume this is impossible to do correctly in crossplatform manner in cmd/terminal. If only there was a way to ask racket repl whether it's fully launched or not...

Eugleo commented 3 years ago

I like the first change, but the second one is too hack-y for my taste 😄 Let's wait till the repl signalizes whether it's loaded or not, or until we find a better way of loading the files.

Eugleo commented 3 years ago

I'm not at the Mac at the moment, could you revert the timer change and resubmit the PR? :-)