harbaum / upide

uPIDE is a simple IDE for Micropython
22 stars 6 forks source link

When LEGO hub times out, source is lost #6

Closed maarten-pennings closed 1 year ago

maarten-pennings commented 2 years ago

I was doing a lot of coding in uPIDE. The LEGO brick switched off after a while. I did a run, uPIDE asked for a reconnect, and my source was LOST!

harbaum commented 2 years ago

You probably never saved your work to the hub but just ran it.

I initially planned to keep the editor windows open until reconnected. But that could cause a mess if you reconnect a different device and then µPIDE gets confused which files belong where.

What I could do is: µPIDE will notice that the connection was lost while you had unsaved changes. It may ask you then if you want to save a copy of your unsaved work onto the PC. You could then reload that saved file later when being reconnected. Would that help?

maarten-pennings commented 2 years ago

I initially planned to keep the editor windows open until reconnected. I actually like that suggestion. For normal LEGO use the scenario of brick switch off is more likely then unitended swapping of hub.

Why not go as follows:

aivarannamaa commented 2 years ago

It seems the user (or uPIDE) could turn off the the automatic turning off behavior: https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/pkg_hub.html#hub.config. Haven't tried it myself yet, though.

harbaum commented 1 year ago

I just uploaded a solution for this. Whenever the connection is lost or upide is closed for other reasons with unsaved changes in open tabs, then the modified data is stored on the PC and the unsaved data is restored on the next startup, giving you a new chance to save.